Can't load native dll

lawson_whitney at lawson_whitney at
Thu Apr 25 15:46:17 CDT 2002

On Thu, 25 Apr 2002, Andriy Palamarchuk wrote:

> Lawson, are you able to load winelib dll from winelib
> application?
> I get the same error whenever I try to do it:
> $ cat test.c
> #include <stdio.h>
> #include <win.h>
> int main(int argc, char **argv)
> {
>     int i;
>     HMODULE h;
>     DWORD le;
>     printf("/%s/\n",GetCommandLine());
>     for (i = 0; i < argc; i++)
>         printf("arg %d: /%s/\n", i, argv[i]);
>     h = LoadLibrary(argv[1]);
>     le = GetLastError();
>     printf("handle %ld last error %ld\n", (long int)h,
> le);
>     return 0;
> }
> $ cp /usr/local/lib/ ./

why are you doing this?  If this is a current Wine, this file is a
hangover from a previous version you didn't uninstall (and nor did I, if
truth be known) and the current builtin dll is named
/usr/local/lib/wine/  The builtin dlls have changed their
unix filenames.  dll name is still msimg32.dll, and that is what you
have to give LoadLibrary.  Wine builtin dlls have to be on WINEDLLPATH.
Don't give it the .so suffix nor the lib prefix, which is obsolete

> $ ./test ./
> /./test ./
> arg 0: /./test/
> arg 1: /./
> err:module:MODULE_LoadLibraryExA Loading of native DLL
> F:\prj\wine_test\ failed (error 193),
> check this file.
> handle 0 last error 193
> Andriy
Another dumb question:  Why do LoadLibrary?  If you import it in the
spec file, it gets loaded automatically.

File cmdl.c not changed so no update needed.
[whit at giftie cmde]$ ./cmdl oops
/./cmdl oops/
cmde dll h 0 le 2
[whit at giftie cmde]$ ./cmdl msimg32.dll oops
/./cmdl msimg32.dll oops/
cmde dll msimg32.dll h 1077043200 le 0
[whit at giftie cmde]$

#include <stdio.h>
#include <winbase.h>
    char red[256];
    unsigned int i,j;
    HMODULE h;
    DWORD le;
    i = (unsigned int) strchr(GetCommandLine(),' ')+1;
    j = (unsigned int) strrchr(GetCommandLine(),' ') - i;
    strncpy(red,(char *) i, j);
    strcpy(red+j, "");
    h = LoadLibrary(red);
    le = GetLastError();
    printf("cmde dll %s h %d le %d\n", red, h, le);

Please don't be offended by the tortured string handling.

name    cmdl
type    win32
mode    guiexe
init    main

import gdi32.dll
import kernel32.dll
import ntdll.dll
import shell32.dll
import user32.dll
import msvcrt.dll


More information about the wine-users mailing list