兄弟我用DELPHI5开发了一个动态连接库,其中输入、输出参数为PCHAR类型,
在使用VC来调用时,有些问题,请问VC中使用什么类型的参数。请各位帮忙解答。

解决方案 »

  1.   

    typedef int (__stdcall * pPrintRecord)(LPTSTR szStr);  //调用打印模版  打印报表
    HINSTANCE hLibrary;
    pPrintRecord PrintRecord;
    hLibrary=LoadLibrary("PrintDll.dll");
    if(!hLibrary)
    {
    ShowMessage2("打印模块PrintDll.dll丢失");
    return;
    }
    PrintRecord=(pPrintRecord)GetProcAddress(hLibrary,"PrintRecord");
    CString str;
    int a= (*PrintRecord)(str.GetBuffer(0));//直接打印
    FreeLibrary(hLibrary);
      

  2.   

    netfyee(VC初学者,DELPHI遗忘中....) 你好。使用你的方法好象不行我的程序是这样的,请指教
    DELPHI中
      function test(var teststr: PChar):integer;stdcall;function test(var teststr: PChar):integer;
    begin
      Result := 0;
      StrPCopy(teststr,'aaaaaaaa');
    end;VC
    typedef int (__stdcall * pTest)(char *szStr);  HINSTANCE hLibrary;
    pTest Test;
    hLibrary=LoadLibrary("test.dll");
    if(!hLibrary)
    {
    AfxMessageBox("can't open dll file");
    return;
    }
    Test=(pTest)GetProcAddress(hLibrary,"test");
    char *buffer;
    int a= (*Test)(buffer);  //此处出错
    CString s=buffer;
        AfxMessageBox(s);
    FreeLibrary(hLibrary);
      

  3.   

    char *buffer;
    int a= (*Test)(buffer);  //此处出错
    -----------------------------
    你还没给buffer分配空间呢,当然会错了。char *buffer;-----》char buffer[100];
      

  4.   

    ajn_sailing(我心飞翔) 你好
    按照你的做法,还是不行
      

  5.   

    错误信息为:
    Unhandled exception in dlltest.exe(test.dll):0xC0000005:Access Violation
      

  6.   

    function test(var teststr: PChar):integer;stdcall改为
    function test(teststr: PChar):integer;stdcall
    因为teststr已经是指针