读写硬件设备的驱动库。
厂家提供了一个DLL文件,还有一个同名的Lib文件
我想在VC中调用,应该怎么做啊?—————————————————————————————————
┏━★━━◆━━★━┓
♂欢|◢CSDN◣|使♂ ▲自由保存帖子,浏览,关注检测
┃迎|◥论坛助手◤|用┃ ▲完善的CSDN客户端工具
┗━☆━━◇━━━☆┛ ▲自动添加签名......让你更快,更爽,更方便地上CSDN...
http://www.csdn.net/expert/topic/573/573604.xml
http://www.chinaok.net/csdn/csdn.zip
厂家提供了一个DLL文件,还有一个同名的Lib文件
我想在VC中调用,应该怎么做啊?—————————————————————————————————
┏━★━━◆━━★━┓
♂欢|◢CSDN◣|使♂ ▲自由保存帖子,浏览,关注检测
┃迎|◥论坛助手◤|用┃ ▲完善的CSDN客户端工具
┗━☆━━◇━━━☆┛ ▲自动添加签名......让你更快,更爽,更方便地上CSDN...
http://www.csdn.net/expert/topic/573/573604.xml
http://www.chinaok.net/csdn/csdn.zip
A Common Object File Format (COFF) file generated by the Microsoft 32-bit Library Manager tool for standard and import libraries. The default file name extension for these files is .lib.
#include <stdio.h> typedef INT (WINAPI *PFNLDBUSER)(LPSAFEARRAY FAR *, PCSTR, INT );
PFNLDBUSER lpfnLdbUser_GetUsers; typedef BSTR (WINAPI *PFNLDBUSERGETERR)(INT);
PFNLDBUSERGETERR lpfnLdbUser_GetError; BOOL ShowUsers(char *); void main( int argc, char* argv[] )
{
if (argc != 2)
return; ShowUsers(argv[1]);
} //
// Display a list of JET users to the console screen.
//
BOOL ShowUsers( char* pszDatabase )
{
HINSTANCE hLdbUserInstance;
SAFEARRAY FAR* psaUserList = NULL;
SAFEARRAYBOUND sabUserList[1];
int cUsers;
LONG iLoop;
HRESULT hr;
char* szBuff;
BOOL fRetVal = TRUE;
BSTR bstrError = NULL; // Get the library instance handle.
hLdbUserInstance = LoadLibrary("MSLDBUSR.DLL");
if (!hLdbUserInstance)
return FALSE; // Get a pointer to the main function in the library.
lpfnLdbUser_GetUsers = (PFNLDBUSER)GetProcAddress(hLdbUserInstance,
"LDBUser_GetUsers");
if (!lpfnLdbUser_GetUsers)
{
fRetVal = FALSE;
goto Exit;
} // Get a pointer to the error function in case an error occurs.
lpfnLdbUser_GetError = (PFNLDBUSERGETERR)GetProcAddress(
hLdbUserInstance, "LDBUser_GetError");
if (!lpfnLdbUser_GetError)
{
fRetVal = FALSE;
goto Exit;
} // Create a SAFEARRAY to hold the list of users.
// NOTE: We'll only create a 1 element array because the
// LDBUser_GetUsers will adjust the size if needed.
sabUserList[0].lLbound = 1;
sabUserList[0].cElements = 1;
psaUserList = SafeArrayCreate(VT_BSTR, 1, sabUserList); // Make the function call and obtain the list of users.
cUsers = lpfnLdbUser_GetUsers(&psaUserList, pszDatabase, 0x1); if (!cUsers )
{
printf("No users\n");
goto Exit;
} // Display error messages if any occurred.
if (cUsers < 0)
{
bstrError = SysAllocString( lpfnLdbUser_GetError( cUsers ) );
printf("Error #:%d -- %s\n",cUsers, bstrError);
goto Exit;
} // Display the list of users.
for(iLoop=1;iLoop <= cUsers; iLoop++)
{
hr = SafeArrayGetElement(psaUserList, &iLoop, &szBuff);
if (SUCCEEDED(hr))
printf("User %d:%s\n",iLoop , szBuff);
else
printf("Failed on User %d\n",iLoop );
} // Cleanup.
Exit:
if (bstrError)
SysFreeString(bstrError); if (psaUserList)
SafeArrayDestroy(psaUserList); // Free up the Msldbusr.dll.
FreeLibrary(hLdbUserInstance); return TRUE;
}
我其实只需要将DLL中的各种函数的说明做成一个.h文件,然后就像普通调用DLL一样调用就行了,
就当那个同名的Lib文件不存在一样是吗?
选上lib文件
在将要调用lib中的文件的前面声名想调用的函数。
that's ok!
和dll配套的lib
和我们说的 lib库不是一个概念。
win32dll可以不声明.def也不需要.lib旧能调用了
其实dll很好用的!
有DLL就够了
LIB可以不用去管
要使用LOADLIBRARY()
FREELIBRARY()