Using C++ dll in VB.Net

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<p style="margin-bottom:0pt; line-height:normal I need to use a C++ dll in vb.Net
<p style="margin-bottom:0pt; line-height:normal
<p style="margin-bottom:0pt; line-height:normal Below is the dumpbin for the dll
<p style="margin-bottom:0pt; line-height:normal
<p style="margin-bottom:0pt; line-height:normal D:Program FilesMicrosoft Visual Studio 10.0VC>dumpbin /exports d:dllmyssort.dll
<p style="margin-bottom:0pt; line-height:normal Microsoft (R) COFF/PE Dumper Version 10.00.30319.01
<p style="margin-bottom:0pt; line-height:normal Copyright (C) Microsoft Corporation.<span>
All rights reserved.
<p style="margin-bottom:0pt; line-height:normal Dump of file d:dll myssort.dll
<p style="margin-bottom:0pt; line-height:normal File Type: DLL
<p style="margin-bottom:0pt; line-height:normal <span> Section contains the following exports for MySort.dll
<p style="margin-bottom:0pt; line-height:normal <span>
00000000 characteristics
<p style="margin-bottom:0pt; line-height:normal <span>
3D3F006E time date stamp Thu Jul 25 01:00:54 2002
<p style="margin-bottom:0pt; line-height:normal <span>
0.00 version
<p style="margin-bottom:0pt; line-height:normal <span>
1 ordinal base
<p style="margin-bottom:0pt; line-height:normal <span>
1 number of functions
<p style="margin-bottom:0pt; line-height:normal <span>
1 number of names
<p style="margin-bottom:0pt; line-height:normal <span>
ordinal hint RVA<span> name
<p style="margin-bottom:0pt; line-height:normal <span>
1<span> 0 00001000 MySortA7
<p style="margin-bottom:0pt; line-height:normal <span> Summary
<p style="margin-bottom:0pt; line-height:normal <span>
1000 .data
<p style="margin-bottom:0pt; line-height:normal <span>
1000 .rdata
<p style="margin-bottom:0pt; line-height:normal <span>
1000 .reloc
<p style="margin-bottom:0pt; line-height:normal <span>
1000 .rsrc
<p style="margin-bottom:0pt; line-height:normal <span>
3000 .text
<p style="margin-bottom:0pt; line-height:normal Below is the function definition which is showing in VB 6 Object Browser.
Function SortA7(udtArray As udtA7Rec, nTotalItems As Long) As Long
<span> Member of MySort. MySort
<span> Sort the elements of A7-type array
Anyone can guide me how to call this method in VB.Net
I tried doing a dllimport like this
<p style="margin-bottom:0pt; line-height:normal; text-align:justify <span style="font-size:9.5pt; font-family:Consolas <<span style="color:#2b91af DllImport(<span style="color:#a31515 "MySort.dll", _
<p style="margin-bottom:0pt; line-height:normal; text-align:justify <span style="font-size:9.5pt; font-family:Consolas SetLastError:=<span style="color:blue True, CharSet:=<span style="color:#2b91af CharSet.Auto)>
<p style="margin-bottom:0pt; line-height:normal; text-align:justify <span style="font-size:9.5pt; color:blue; font-family:Consolas Public<span style="font-size:9.5pt; font-family:Consolas
<span style="color:blue Function SortA7(<span style="color:blue ByVal udtArray
<span style="color:blue As MySort<span style="font-size:9.5pt; font-family:Consolas .<span style="color:#2b91af udtA7Rec(),
<span style="color:blue ByVal nTotalItems <span style="color:blue As
<span style="color:blue Long) <span style="color:blue As <span style="color:blue
Long
<span style="font-size:9.5pt; color:blue; font-family:Consolas End<span>
<span>Function
<span><span>
<p style="margin-bottom:0pt; line-height:normal; text-align:justify
But its giving me an error<span> “Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”
<span>
<span>Please help

View the full article
 
Back
Top