Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to output the DLL creation of VB.NET function

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to create the DLL of VB.NET output function, the article is very detailed, has a certain reference value, interested friends must read it!

The VB compilation file actually compiles twice, first by calling c2.exe to generate the OBJ file, and then by calling the Link.exe connection. If you add the EXPORT option when you link, you can actually output the function. However, these are masked in VB's engineering options. And it goes too far: VB deletes the OBJ file after the Build is completed, so it is impossible to output the function through Link. However, I found a dirty workaround, which is to create an Exe project first and write the following statement in the Form_Load event:

Private Sub Form_Load () If (MsgBox ("hehe", vbOKCancel) = vbOK) Then Shell "link2.exe" & Command$ End If End End Sub

Then compile to linktemp.exe, then rename LINK.EXE to Link2.exe and linktemp.exe to link.exe. This will pop up the dialog box when VB calls link.exe, and the processing will be interrupted. At this point, you can have the opportunity to copy the OBJ file out, J.

Then I create an ActiveX DLL project, add a Module to the project and create a Public function mathadd:

Public Function mathadd (ByVal an As Long, ByVal b As Long) As Long mathadd = a + b End Function

The Builder project will be interrupted at the time of Link. Then back up the created Class1.obj, Module1.obj, and Project1.obj.

Then you can call Link2.exe to connect OBJ to DLL. My connection code is:

Link2.exe "e:\ vbdll\ Class1.obj"e:\ vbdll\ Module1.obj"e:\ vbdll\ Project1.obj"

"E:\ Program Files\ Microsoft Visual Studio\ VB98\ VBAEXE6.LIB" / ENTRY:__vbaS / EXPORT:mathadd / OUT:

"e:\ vbdll\ ProjectOK.dll" / BASE:0x11000000 / SUBSYSTEM:WINDOWS,4.0 / VERS

Notice the / ENTRY and / EXPORT switches inside, and the / EXPORT switch declares the output function mathadd. So you're done:-D, which can be introduced by other languages, such as in VB, just:

Private Declare Function mathadd Lib "e:\ vbdll\ ProjectOK.dll" (ByVal an As Long, ByVal b As Long) As Long above is all the content of this article "how to output DLL creation of VB.NET function". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report