说明:获取一个已装载模板的完整路径名称 
返回值:Long,如执行成功,返回复制到lpFileName的实际字符数量;零表示失败。会设置GetLastError 
参数表 
参数                类型及说明 
hModule             Long,一个模块的句柄。可以是一个DLL模块,或者是一个应用程序的实例句柄 lpFileName String,   指定一个字串缓冲区,要在其中容纳文件的用NULL字符中止的路径名,         hModule模块就是从这个文件装载进来的 
nSize Long,          装载到缓冲区lpFileName的最大字符数量 注解: 
在Windows 95下,函数会核查应用程序的内部版本号是否为4.0或更大的一个数字。如果是,就返回一个长文件名,否则返回短文件名
 

解决方案 »

  1.   

    最常用的是这个参数为0,这是返回的是exe文件的全路径文件名。
      

  2.   

    给你个例子自己看吧
    'Example Name:ModuleFilename
    Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
    Private Declare Function GetWindowWord Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long) As Integer
    Const GWW_HINSTANCE = (-6)
    Private Sub Form_Load()
        Dim ModuleName As String, FileName As String, hInst As Long
        'create a buffer
        ModuleName = String$(128, Chr$(0))
        'get the hInstance application:
        hInst = GetWindowWord(Me.hwnd, GWW_HINSTANCE)
        'get the ModuleFileName:
        'enter the following two lines as one, single line:
        ModuleName = Left$(ModuleName, GetModuleFileName(hInst, ModuleName, Len(ModuleName)))
        'set graphics mode to persistent
        Me.AutoRedraw = True
        'show the module filename
        Me.Print "Module Filename: " + ModuleName
    End Sub
      

  3.   

    Dim ModuleName as String
    ModuleName = String$(250, Chr$(0))
    ModuleName = left$(ModuleName, GetModuleFileName(App.hInstance, ModuleName, Len(ModuleName)))