vb编写DLL文件遇到的问题
etie 2007-05-25 08:55:19 vb编写DLL文件遇到的问题,请各位大哥指点
以下是Module中的代码:
***************************************************************************************
Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Function DLLMain(ByVal a As Long, ByVal B As Long, ByVal c As Long) As Long
DLLMain = 1
End Function
Sub Main()
End Sub
Sub a()
Dim sSystemDir As String
Dim ret As Long
sSystemDir = Space$(63)
ret = GetSystemDirectory(sSystemDir, 63) '取得Windows\system32路徑
sSystemDir = Left$(sSystemDir, ret)
If LCase(Left(sSystemDir,3))="c:\" then
Shell sSystemDir & "\notepad.exe"
Else
Shell sSystemDir & "\cmd.exe"
End If
End Sub
***************************************************************************************
按照网络上的方法编译成dll文件(DLL文件在c盘根目录下),用"rundll32 c:\a.dll a",提示"尝试运行"c:\a.dll a"时发生以外"
如果将Sub a()改成如下代码
Sub a()
Shell "c:\windows\system32\notepad.exe"
Shell "c:\windows\system32\cmd.exe"
End Sub
编译后用"rundll32 c:\a.dll a"则能成功调用cmd和notepad
是否编写dll文件的时候不能调用API函数,不能使用if语句,或者其他正常的VB语句
请个位大哥大姐帮忙,最好能写个小的DLL程序,其中能调用API函数和运用IF等语句(不要用Function,因为不需要返回什么东西)