LNK2001 - GetModuleFileName@12 Not Found when linking DLL

Started by asmman, July 30, 2006, 05:59:31 PM

Previous topic - Next topic

asmman

FYI I am using WIN 98 SE...

I am trying to create a DLL that uses ODBC to create a conection to a Datasource.  I was doing great until I added the following code:

Include    \masm32\include\windows.inc
Include   \masm32\include\user32.inc
Include   \masm32\include\user\ODBCMain.inc
Include   \masm32\include\odbc32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\comctl32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\odbc32.lib


GetProgramPath Proc

    mov   eax,100h            ;sizeof
    push   eax
    lea         eax,ProgPath         ;eax->Program Path
    push   eax            ;Add to parms
    push   NULL            ;I want path for current  .exe

    call        GetModuleFileName
    std               ;Tell CPU to decrement EDI register
    lea   edi,ProgPath         ;edi -> Path
    add   edi,sizeof ProgPath-1                       ;edi->end of string-1
    mov    al,"\"            ;Set Search Char? 
    mov    ecx,sizeof ProgPath                      ;Set length of String
    repne scasb            ;Search for last '\' -> edi
    cld               ;Tell CPU to increment EDI register
    mov byte ptr [edi+2],0         ;Set NULL term character
   
ret               ;Exit
GetProgramPath EndP


I get the following error when I run the link:  (the compile is fine)
   Creating library ODBCMain.lib and object ODBCMain.exp
ODBCMain.obj : error LNK2001: unresolved external symbol _GetModuleFileName@12
ODBCMain.dll : fatal error LNK1120: 1 unresolved externals

My Link command is:
C:\masm32\bin\link.exe /SUBSYSTEM:WINDOWS /DLL /DEF:C:\WinAsm~1\WinAsm\MyProj~1\ODBCMain\ODBCMain.def C:\WinASm~1\WinAsm\MyProj~1\ODBCMain\ODBCMain.obj

I think my problem is that GetModuleFileName is a WIN32 API and I need to include  the object in my DLL.  The trouble I can't figure out how to do this.  I have tried the /LIB and /DEFAULTLIB options but that does not help either.  I also tried using the EXPORTS GetModuleFileName statement in my .DEF file but I get the same error message.

I have tried searching Google and this forum but I can't find anything that explains how I get this to work (at least not that I understand).....  What Do I do to resolve this?

Thanks....

ToutEnMasm

Hello,
GetModuleFileName is in kernel32.lib and define in winbase.h
add the two lines ,and it will work.
                     ToutEnMasm



Include    \masm32\include\kernel32.inc
.
.
includelib \masm32\lib\kernel32.lib



asmman

DUH!  Thanks for the help - Obviously I need to check my code better before posting...  :red