Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从C+;调用的Delphi DLL中未显示ShowMessage+; 我想用C++从DLL调用这个Delphi代码 procedure MyMessage; stdcall; begin ShowMessage(DLLName + ' more text'); end; 使用一些Delphi测试代码,我没有发现任何问题,但是从C++中没有显示任何消息框。 我做了以下C++代码< /P> // function prototype typedef void(__stdcall*VoidCall)(); // prototype for info function inside DLL extern "C" __declspec(dllimport) void __stdcall MyMessage(); MyMessage = (VoidCall)::GetProcAddress(load, "MyMessage"); MyMessage; 我想用下一步的步骤,用C++的包装DLL来实现Delphi表单,我猜这个问题的解决方案也会使我下一个任务……< /P> < P> C++代码没有编译。它将通过导入库绑定dll与通过LoadLibrary/GetProcAddress动态加载dll混合在一起_C++_Delphi_Dll - Fatal编程技术网 < P> C++代码没有编译。它将通过导入库绑定dll与通过LoadLibrary/GetProcAddress动态加载dll混合在一起,c++,delphi,dll,C++,Delphi,Dll" /> < P> C++代码没有编译。它将通过导入库绑定dll与通过LoadLibrary/GetProcAddress动态加载dll混合在一起,c++,delphi,dll,C++,Delphi,Dll" />

从C+;调用的Delphi DLL中未显示ShowMessage+; 我想用C++从DLL调用这个Delphi代码 procedure MyMessage; stdcall; begin ShowMessage(DLLName + ' more text'); end; 使用一些Delphi测试代码,我没有发现任何问题,但是从C++中没有显示任何消息框。 我做了以下C++代码< /P> // function prototype typedef void(__stdcall*VoidCall)(); // prototype for info function inside DLL extern "C" __declspec(dllimport) void __stdcall MyMessage(); MyMessage = (VoidCall)::GetProcAddress(load, "MyMessage"); MyMessage; 我想用下一步的步骤,用C++的包装DLL来实现Delphi表单,我猜这个问题的解决方案也会使我下一个任务……< /P> < P> C++代码没有编译。它将通过导入库绑定dll与通过LoadLibrary/GetProcAddress动态加载dll混合在一起

从C+;调用的Delphi DLL中未显示ShowMessage+; 我想用C++从DLL调用这个Delphi代码 procedure MyMessage; stdcall; begin ShowMessage(DLLName + ' more text'); end; 使用一些Delphi测试代码,我没有发现任何问题,但是从C++中没有显示任何消息框。 我做了以下C++代码< /P> // function prototype typedef void(__stdcall*VoidCall)(); // prototype for info function inside DLL extern "C" __declspec(dllimport) void __stdcall MyMessage(); MyMessage = (VoidCall)::GetProcAddress(load, "MyMessage"); MyMessage; 我想用下一步的步骤,用C++的包装DLL来实现Delphi表单,我猜这个问题的解决方案也会使我下一个任务……< /P> < P> C++代码没有编译。它将通过导入库绑定dll与通过LoadLibrary/GetProcAddress动态加载dll混合在一起,c++,delphi,dll,C++,Delphi,Dll,要加载用Delphi创建的DLL,最简单的方法是使用动态加载DLL。按以下步骤执行此操作: // function prototype typedef void(__stdcall*VoidCall)(); [……] 如果您想使用加载时间链接,可以创建一个*+LB文件,用于C++与Delphi一起创建的DLL。使用。中的解决方案提问时,请完整介绍工作和编译代码片段。请参阅@DavidHeffernan Answer adapted编译和使用dll中的几个函数,这些函数工作正常;我猜消息框

要加载用Delphi创建的DLL,最简单的方法是使用动态加载DLL。按以下步骤执行此操作:

//  function prototype 
typedef void(__stdcall*VoidCall)();
[……]



如果您想使用加载时间链接,可以创建一个*+LB文件,用于C++与Delphi一起创建的DLL。使用。

中的解决方案提问时,请完整介绍工作和编译代码片段。请参阅@DavidHeffernan Answer adapted编译和使用dll中的几个函数,这些函数工作正常;我猜消息框(DELPHI代码:ShowMessage(..)没有连接到我的表单,这就是为什么我看不到任何东西的原因…没有括号的代码MyMessage不会调用该方法。这真的是你的代码吗?如果是,则尝试添加括号?如果没有,请向我们展示您的真实代码。在函数调用中添加括号后,问题已经解决!谢谢你的回答
// Load the library
HMODULE lib = LoadLibrary("Project1.dll");
if (lib != 0)
{
    __try
    {
        // Get the address to the exported function in the DLL
        // and store it in the variable myMessageFunction
        VoidCall myMessageFunction = (VoidCall) GetProcAddress(lib, "MyMessage");

        // Call the function. Note you need the parenthesis even
        // when there are no parameters to pass
        myMessageFunction();
    }
    __finally
    {
        // Unload the library again. Note that you cannot use 
        // functions from the library after that. So only unload
        // the dll once you don't need it anymore.
        FreeLibrary(lib);
    }
}
else // TODO: Error handling, dll cannot be loaded