在读第一章时,书中说以DLL的方式重用一个类,而我只知道在怎么DLL中输出函数(delphi中),怎么从DLL中导出一个函数、类??调用时应如何声明?最好贴个源代码,越简单越好。

解决方案 »

  1.   

    如果不是用com导出类,那么参考
    www.codeguru.com/dll
      

  2.   

    Extension DLLs use the macro AFX_EXT_CLASS to export classes; the executables that link to the extension DLL use the macro to import classes. With the AFX_EXT_CLASS macro, the same header file(s) used to build the extension DLL can be used with the executables that link to the DLL.In the header file for your DLL, add the AFX_EXT_CLASS keyword to the declaration of your class as follows:class AFX_EXT_CLASS CMyClass : public CDocument
    {
    // <body of class>
    };
      

  3.   

    typedef BOOL (* UrlFunc) (LPCTSTR pszPath);
    BOOL re;
    LPCTSTR dllname = _T("shlwapi.dll");
    LPCTSTR Funname = _T("PathIsURL");
    HINSTANCE hIns = LoadLibrary(dllname);
    if (hIns)
    {
    UrlFunc urlfunc = (UrlFunc) GetProcAddress(hIns,Funname);
    if(urlfunc)
    re = urlfunc(urlstr); 
    FreeLibrary(hIns); }