Looking for a LoadLibrary C example that works with GCC

So far I found this:

http://www.sharetechnote.com/html/C_LoadLibrary.html

Removed stdafx.h

Added

#include "tchar.h"

it compiles fine, but throws a note and warning

hangs a bit and exits.

1
2
3
warning: passing argument 1 of 'LoadLibraryA' from incompatible pointer type [enabled by default]

note: expected 'LPCSTR' but argument is of type 'short unsigned int *'


Last edited on
note: expected 'LPCSTR' but argument is of type 'short unsigned int *'

At a glance, get rid of the encoding prefix on any string literals. For example, try changing L"whatever" to "whatever"
Last edited on
Thanks mbozzi and it works!
Last edited on
LoadLibraryA means you're compiling as ASCII and not unicode. Hence strings should be specified as ASCII and not unicode (eg no L in front).

Many WIN32 functions have 2 versions those ending in A (ASCII) and those ending in W (WIDE - unicode). For those without an ending A/W that support either ASCII/Unicode then which is sued depends upon whether UNICODE/_UNICODE is defined or not. Same with T in the type. LPCSTR is ASCII, LPWSTR is unicode but LPTSTR is either depending upon whether compiling as ASCII or Unicode.

If you want to explicitly use a ASCII or Unicode version of a WIN32 function, then use the A or W version. ie LoadLibraryW(L"unicodefilename");
Topic archived. No new replies allowed.