使用C语言创建DLL [英] DLL creation with C language

查看:172
本文介绍了使用C语言创建DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Visual C ++编程的新手,需要将DLL文件集成到3个第三方工具(WWB-COM)中。  

I am new with visual C++ programming, and need to integrate the DLL file in to 3 third party tool (WWB-COM).  

用于生成DLL的工具:Visual C ++ 2008

Tools used for DLL generation: Visual C++ 2008

用于调用DLL的工具:WinWrap Basic,也是VB6,VB.Net兼容。

Tools used for calling DLL: WinWrap Basic, which is also VB6, VB.Net compatible.

我读了Howto docs作为链接&https://support.microsoft.com/en-us/kb/205277?wa = wsignin1.0并尝试重现在我的环境中演示。

I read throgh the Howto docs as link https://support.microsoft.com/en-us/kb/205277?wa=wsignin1.0 and try to reproduce the demo in my environment.

实现如下

步骤1:创建DLL项目。

step 1: create a DLL Project.

第2步:在stdad.h文件中添加 #define INC_OLE2

step 2: add #define INC_OLE2 in the stdad.h file

#define INC_OLE2                // Add by Huayang WANG

第3步:在StdDLL.cpp中定义一个函数协议文件。 

step 3: define a function protocol in StdDLL.cpp file. 

Long __declspec (dllexport) __stdcall Func1(Long *pnFirstElement, Long lSize){
    Return 1;
}

第4步构建项目并生成DLL并生成地图文件。 

step 4 build the project and generate DLL and generate map file. 

奇怪的是我找不到装饰的函数名称地图文件。根据该文件,如果用
__ declspec(dllexport)声明,则装饰名称的格式应为_< function> @< param bytes的长度>。在我的情况下应该是_func1 @ xx。但事实并非如此。

it is strange that i can't find the decorated function name in map file. according to the document, if declared with __declspec (dllexport) the decorated name should be in format of _<function>@<length of param bytes>. in my case should be _func1@xx. But it is not.

步骤5在WWB-COM中声明DLL。并完成函数所需的参数集。但是当我尝试运行时,它失败并且 症状
是无法加载模块。

'#Language "WWB-COM"
Declare Function Func1 Lib "D:\9_Tools\50_DLL\StdDLL\Debug\StdDLL.lib" _
    (ByRef FirstElement As Long, ByVal Size As Long)
Option Explicit


Sub Main
    Dim result As Long
    Dim MyArrayOfLongs(3) As Long
    MyArrayOfLongs(0) = 0
    MyArrayOfLongs(1) = 1
    MyArrayOfLongs(2) = 2
    MyArrayOfLongs(3) = 3

    result = Func1(MyArrayOfLongs(0),4)
    MsgBox("Func1 returned " & result)
    
End Sub




有人可以给我一个提示以避免这种情况吗?

BR

华阳

推荐答案

我认为你应该在VB中指定.dll文件而不是.lib。

I think that you should specify the .dll file instead of .lib in VB.

要检查导出的函数,请使用"Dependency Walker"免费工具。它还将显示装饰名称,有时可以使用声明函数语句中的
别名定义来指定。

In order to check the exported functions, use the "Dependency Walker" free tool. It will also show the decorated name, which can be specified sometimes using Alias definition in Declare Function statement.

这篇关于使用C语言创建DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆