读写硬件设备的驱动库。
厂家提供了一个DLL文件,还有一个同名的Lib文件
我想在VC中调用,应该怎么做啊?—————————————————————————————————
┏━★━━◆━━★━┓ 
♂欢|◢CSDN◣|使♂        ▲自由保存帖子,浏览,关注检测
┃迎|◥论坛助手◤|用┃        ▲完善的CSDN客户端工具
┗━☆━━◇━━━☆┛       ▲自动添加签名......让你更快,更爽,更方便地上CSDN...
http://www.csdn.net/expert/topic/573/573604.xml
http://www.chinaok.net/csdn/csdn.zip

解决方案 »

  1.   

    同MFC类库函数一样用,把lib苦link到工程,,dll放到工程目录下,包含头文件即可使用
      

  2.   

    我想请教一下,DLL和LIB的关系。因为以前在其它语言内调用DLL就是一个单纯的DLL文件,那现在的LIB文件有什么作用呢?
      

  3.   

    LIB作为DLL的引入库,原来调用DLL需要在应用里LoadLibrary(...),GetProcAdress(...)云云~~~,As an alternative,现在只要加入lib和头文件,就可以在程序中像用普通函数那样,简单!
      

  4.   

    但凡DLL一般都会有个LIB文件(单纯的DLL除外),LIB文件标识了DLL类型库信息,如名称,导出函数等,DLL则为可以执行的代码,但必须依赖于特定的可执行程序。.lib file 
    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. 
      

  5.   

    隐式连结dll,同连结其它的.lib的过程一样,需要同文件,并同dll的.lib文件连结就可以了。
      

  6.   

    如果是那样,我可不可以只用DLL不用LIB呢?
      

  7.   

    可,写好DLL函数原型,LoadLibrary即可Sample Code   #include <windows.h>
       #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;
       } 
      

  8.   

    你的意思是说厂家提供的Dll和Lib文件只不过是为了提供两种调用方式而已。
    我其实只需要将DLL中的各种函数的说明做成一个.h文件,然后就像普通调用DLL一样调用就行了,
    就当那个同名的Lib文件不存在一样是吗?
      

  9.   

    project -->add file to project
     选上lib文件
    在将要调用lib中的文件的前面声名想调用的函数。
    that's ok!
      

  10.   

    看你的dll作的好不好了,如果里面定义了.def文件(声明了dll的入口),就可以不用lib,如果没定义就需要用(lib对dll的入口进行了声名)。
    和dll配套的lib
    和我们说的 lib库不是一个概念。
    win32dll可以不声明.def也不需要.lib旧能调用了
    其实dll很好用的!
      

  11.   

    只要知道函数定义
    有DLL就够了
    LIB可以不用去管
    要使用LOADLIBRARY()
    FREELIBRARY()