因為你在C的這邊函式宣告沒有使用STDCALL宣告,而DELPHI用的則用了STDCALL故造成問題.
方法一: 改DELPHI程式碼:
function login(name,password:pchar):Integer;stdcall;
改成
function login(name,password:pchar):Integer;cdecl;
當C函式不使用STDCALL方式宣告時, 預設的約定叫C declare (看字面意思就應該明白,C的函式宣告方式)
DELPHI對應的就是cdecl
方法二: 改C部分程式碼
extern "C" _declspec(dllexport) int login(char *name,char *password)
extern "C" _declspec(dllexport) __stdcall int login(char *name,char *password)
因為你在C的這邊函式宣告沒有使用STDCALL宣告,而DELPHI用的則用了STDCALL故造成問題.
方法一: 改DELPHI程式碼:
function login(name,password:pchar):Integer;stdcall;
改成
function login(name,password:pchar):Integer;cdecl;
當C函式不使用STDCALL方式宣告時, 預設的約定叫C declare (看字面意思就應該明白,C的函式宣告方式)
DELPHI對應的就是cdecl
方法二: 改C部分程式碼
extern "C" _declspec(dllexport) int login(char *name,char *password)
改成
extern "C" _declspec(dllexport) __stdcall int login(char *name,char *password)