因應Win XP to Win 7 to Win 10的驅動程式可能使用的DLL不同,所以到網路上找了一些方法來解決。
PS. 由於BCB 6.0只支援32bit的Compiler,所以作業系統也只能同時都是32bit
1. 下載工具程式,確認DLL內的Function名稱
2. 編寫軟體,目前的寫法是用來判斷是不是64位元作業系統,但是因為BCB不支援64bit,所以就算可以正常載入MN200DLL_64.dll,軟體也沒辦法執行。
#include windows.h
typedef bool(WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);LPFN_ISWOW64PROCESS fnIsWow64Process;HINSTANCE hInst;short __stdcall (*Dll_mn_open_all)(BYTE* pNumLine);bool IsWow64() //判斷是不是64位元作業系統{int bIsWow64=0;//IsWow64Process is not available on all supported versions//of Windows. Use GetModuleHandle to get a handle to the//DLL that contains the function and GetProcAddress to get//a pointer to the function if available.fnIsWow64Process=(LPFN_ISWOW64PROCESS) GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process");if(NULL!=fnIsWow64Process){if(!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)){//handle error}}return bIsWow64;}//---------------------------------------------------------------------------__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner){if(IsWow64()) //如果是64位元作業系統{Button1->Caption="X64";hInst=LoadLibrary("MN200DLL_64.dll");(FARPROC &)Dll_mn_open_all=GetProcAddress(hInst, "_mn_open_all");}else{Button1->Caption="X32";hInst=LoadLibrary("MN200DLL.dll");(FARPROC &)Dll_mn_open_all=GetProcAddress(hInst, "_mn_open_all@4"); //Function名稱由DLL Export Viewer裡面確認}int X=GetLastError(); //確認是否有錯誤碼}