Func _EzMySql_Startup($hEzMySql_DllLoc = "")
Local $sDll_Filename, $hFileCreate, $hFileWriteOk
If @AutoItX64 = 0 Then
$sDll_Filename = "libmysql.dll"
Else
$sDll_Filename = "libmySQL_x64.dll"
EndIf
If $hEzMySql_DllLoc Then
If StringRight($hEzMySql_DllLoc, StringLen($sDll_Filename)) <> $sDll_Filename Then
$hEzMySql_DllLoc = StringRegExpReplace($hEzMySql_DllLoc, "[\\/]+\z", "") & ""
$hEzMySql_DllLoc &= $sDll_Filename
EndIf
Else
$hEzMySql_DllLoc = @ScriptDir & "" & $sDll_Filename
EndIf
If Not FileExists($hEzMySql_DllLoc) Then
$hFileCreate = FileOpen($hEzMySql_DllLoc, 10)
$hFileWriteOk = FileWrite($hFileCreate, _EzMySql_Dll())
FileClose($hFileCreate)
If Not $hFileWriteOk Then Return SetError(1, 0, 0)
EndIf
$hEzMySql_Dll = DllOpen($hEzMySql_DllLoc)
If $hEzMySql_Dll = -1 Then Return SetError(2, 0, 0)
Local $hPtr = DllCall($hEzMySql_Dll, "ptr", "mysql_init", "ptr", 0)
If @error Then Return SetError(3, 0, 0)
$hEzMySql_Ptr = $hPtr[0]
Return 1
EndFunc
LZ难道没看到这段代码吗?
_EzMySql_Startup()这个udf在运行时会检测libmysql.dll是否不存在,不存在就调用EzMySql_Dll.au3生成一个dll文件在脚本当前目录下.
俺一般喜欢用flieinstall把libmysql.dll这个文件释放到system32文件夹下,然后 _EzMySql_Startup(@systemdir"\libmysql.dll"),或者也可以把文件放到ftp上,脚本运行时用fileexists函数检测system32下是否存在此dll,不存在就从ftp上inget... |