好,我现在在VB上面写了这样的语句生成Active X DLL,在这里也就是一句话,通过这句话调用普通DLL,那现在我在ASP上再创建这个Active X DLL上的对象,之后调用VC写的普通DLL上的函数有错误!我的Active X DLL名字为:Texturedll.dll,已经成功注册,VC DLL已经COPY到了SYSTEM32目录下!!一切按照常规进行,我怀疑是vb 声明VC DLL函数那一步骤发生了错误,高手帮我看看大家帮我看看
VB Active X DLL:Private Declare Sub TextureSearch Lib "Texturedll" (ByVal Path As String)ASP :Set testDll = Server.CreateObject("PatentImage.ImageDll")
testDll.TextureSearch("E:/Path.bmp")
但是最后系统报出错误说对象不支持TextureSearch这个方法,不知道错在了那里?

解决方案 »

  1.   

    我顺便把VC函数里面的定义也写出来把
    VC:
    extern "C" _declspec(dllexport) void TextureSearch(CString Imagepath)
    {
    //初始化局部变量
    Acesstxt* pacesstxt;
    pacesstxt = new Acesstxt();
    CDib pcdib;
    CGrayShow pgrayshow;
    DataBase1 database;
    CString m_sImageName;
    .............
    }
      

  2.   

    各位高手帮帮忙,为了解决,顺便把初始化代码也贴出来拉static AFX_EXTENSION_MODULE TexturedllDLL = { NULL, NULL };extern "C" int APIENTRY
    DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
    {
    // Remove this if you use lpReserved
    UNREFERENCED_PARAMETER(lpReserved); if (dwReason == DLL_PROCESS_ATTACH)
    {
    TRACE0("TEXTUREDLL.DLL Initializing!\n");

    // Extension DLL one-time initialization
    if (!AfxInitExtensionModule(TexturedllDLL, hInstance))
    return 0; // Insert this DLL into the resource chain
    // NOTE: If this Extension DLL is being implicitly linked to by
    //  an MFC Regular DLL (such as an ActiveX Control)
    //  instead of an MFC application, then you will want to
    //  remove this line from DllMain and put it in a separate
    //  function exported from this Extension DLL.  The Regular DLL
    //  that uses this Extension DLL should then explicitly call that
    //  function to initialize this Extension DLL.  Otherwise,
    //  the CDynLinkLibrary object will not be attached to the
    //  Regular DLL's resource chain, and serious problems will
    //  result. new CDynLinkLibrary(TexturedllDLL);
    }
    else if (dwReason == DLL_PROCESS_DETACH)
    {
    TRACE0("TEXTUREDLL.DLL Terminating!\n");
    // Terminate the library before destructors are called
    AfxTermExtensionModule(TexturedllDLL);
    }
    return 1;   // ok

    }
      

  3.   

    不用这么做,在vb中可以不用声明api的方式调用dll,你可以先注册vc写的dll,方法是在运行对话框中输入regsvr32.exe c:\mydll.dll,然后在vb的引用中引用该dll即可。类似于引用ado对象。
      

  4.   

    不行的,VC写的普通DLL是不可以注册的,只有VB写的ActiveX Dll才能正常注册
      

  5.   

    VC参数错误,试着将参数改成LPCTSTR或者BSTR试试看.VC不能把VB的String转化成CString的
      

  6.   

    更正:
    不是 VC不能把VB的String转化成CString的是不能自动
      

  7.   

    把Private 改为Public试试.
    这样声明:Public Declare Sub TextureSearch Lib "你的VCdll.dll" (ByVal Path As String)
      

  8.   

    好的,谢谢楼上的大虾我看了一下,我用了一个不用参数的函数测试了一下,系统也报出说不支持该方法
    大家帮我看看vc:
    extern "C" _declspec(dllexport) bool _stdcall JustSoSo()
    {
    MessageBox(NULL,"It's so easy!","Hahaha......",MB_OK);
    return true;
    }VB:
    Private Declare Function JustSoSo Lib "Texturedll" () As Booleanasp:
    <%
            dim can
    Set testDll = Server.CreateObject("PatentImage.ImageDll")
    can = testDll.JustSoSo
    %>
      

  9.   

    可以在VB里创建一个方法,把VC的函数封装一下。我说的改成Public是要放在类模块里。不行的话就只有加一个方法:public sub done()
     JustSoSo
    end sub
    Set testDll = Server.CreateObject("PatentImage.ImageDll")
    can = testDll.done
      

  10.   

    为什么非用VB呢?用ATL做一个ActiveX Dll不就没这么费事了吗
      

  11.   

    谢谢汗衫!!!!!!!!!我在这里向你致谢拉!我也想用ActiveX dll做!不过因为VC那部分不是我做的,但是我要完成的任务就是要成功调用它!!
    不过如果可以的话,我也想用ActiveX dll来做,不知道做Active dll和做普通Dll区别大吗?
      

  12.   

    另外还有个问题!我注册了ActiveX dll后,之后不用,用反注册命令把它从组件里面去掉,但是我还想把它从磁盘删除出去,不知道有什么方法把它给删除出去呢?
      

  13.   

    没错,CString你用错了,VB不能够调用CString的,快吧它改成char *就可以了,至于CString和
    char *的相互转换方法网上有一大巴,  我上个星期的项目也有过这种情况或者你可以采用VC直接做OCX也可以,但是太累了,还是用VB吧
      

  14.   

    我又想到了,如果不方便改的话,可以用VC做一个转接函数,调用原来的DLL,新的引出接口做成char *声明的,这样也可以。
      

  15.   

    不知道VC的LPCTSTR类型可不可以和VB string类型互换
      

  16.   

    cou同学,你的做法有问题哎, :),
    我来说一下基本过程,具体操作你自己做啦首先要有一个普通的DLL,比方 NormalDLL.dll
    里面有个普通的Win32函数  Win32ApiFunc那么在VB的ActiveX DLL 中,我们记做  ActiveXDLL.dll
    要有一个共用的Class, PublicClass.cls在那个PublicClass.cls里面要有 Win32ApiFunc的函数申明
    private Declare .... Win32ApiFunc ....
    然后给PublicClass 添加一个共用的方法
    Public Function ... Win32ApiFuncWrap(....)
      在这个函数里面调用  Win32ApiFunc 最后在你的asp脚本中就可以
    set o = CreateObject(ActiveXDLL.PublicClass")
    o.Win32ApiFuncWrap(...) 来达到调用普通DLL函数的目的了
      

  17.   

    我想你是漏掉了添加一个 Win32ApiFuncWrap 的封装函数