473,396 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

calling a Visual C dll

How do I declare and call a function in a dll with VB.NET? The prototype
for my function is

extern "C" BOOL PASCAL EXPORT CreateProxCodes(char *formatpath, char
*formatname, struct CPSWorkOrder cpswo)

and the dll is called proxprog.dll, which is created with VC6

Thanks
Nov 21 '05 #1
3 1888

"Dave Cullen" <no*****@mail.com> wrote in message
news:41***************@mail.com...
How do I declare and call a function in a dll with VB.NET? The prototype
for my function is

extern "C" BOOL PASCAL EXPORT CreateProxCodes(char *formatpath, char
*formatname, struct CPSWorkOrder cpswo)

and the dll is called proxprog.dll, which is created with VC6


Breaking this down

extern "C"

means to export the function without a C++ mangled name

BOOL

is a typedef for int. It should convert automatically to Boolean.

PASCAL

is defined as __stdcall, which is the default calling convention for
DllImport

char *

is a null terminated array of chars in the ANSI charset, which is the
default marshalling for String.

CPSWorkOrder

is a struct defined elsewhere in your VC6 header file. It must be declared
in VB as well.

EG for

struct CPSWorkOrder
{
int id;
char name[12];
};

It would be something like this
<StructLayout(LayoutKind.Sequential)> _
Structure CPSWorkOrder
Public id As Int32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=12)> _
Public name As String
End Structure

<DllImport("proxyprog.dll")> _
Function CreateProxCodes(formatpath as string, formatname as string, cpswo
as CPSWorkOrder)
Nov 21 '05 #2
Thanks for the info. I'm getting closer...

When I try to call the exported function, VB throws an exception "Unable
to find an entry point named CreateProxCodes" in the dll. Is there
anything that'd keep a VB.NET app from seeing the function?

drc
David Browne wrote:

"Dave Cullen" <no*****@mail.com> wrote in message
news:41***************@mail.com...
How do I declare and call a function in a dll with VB.NET? The prototype
for my function is

extern "C" BOOL PASCAL EXPORT CreateProxCodes(char *formatpath, char
*formatname, struct CPSWorkOrder cpswo)

and the dll is called proxprog.dll, which is created with VC6


Breaking this down

extern "C"

means to export the function without a C++ mangled name

BOOL

is a typedef for int. It should convert automatically to Boolean.

PASCAL

is defined as __stdcall, which is the default calling convention for
DllImport

char *

is a null terminated array of chars in the ANSI charset, which is the
default marshalling for String.

CPSWorkOrder

is a struct defined elsewhere in your VC6 header file. It must be declared
in VB as well.

EG for

struct CPSWorkOrder
{
int id;
char name[12];
};

It would be something like this

<StructLayout(LayoutKind.Sequential)> _
Structure CPSWorkOrder
Public id As Int32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=12)> _
Public name As String
End Structure

<DllImport("proxyprog.dll")> _
Function CreateProxCodes(formatpath as string, formatname as string, cpswo
as CPSWorkOrder)

Nov 21 '05 #3

"Dave Cullen" <no*****@mail.com> wrote in message
news:41**************@mail.com...
Thanks for the info. I'm getting closer...

When I try to call the exported function, VB throws an exception "Unable
to find an entry point named CreateProxCodes" in the dll. Is there
anything that'd keep a VB.NET app from seeing the function?

drc


Open the Visual Studio .Net 2004 Command Prompt and run

dumpbin /exports proxprog.dll

This will print a table of all of the entry points in the .dll.

David
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Glenn A. Harlan | last post by:
Why am I receiving the below error when calling - Path.GetTempFileName() The directory name is invalid. Description: An unhandled exception occurred during the execution of the current web...
3
by: Ken | last post by:
hello, I would to know if it is possible to call an object in a function within a class. Meaning , In a class, A function X calling onto a function Y, and function Y we want one of the two...
2
by: Ray J. | last post by:
I have a C++ program written and compiled on Solaris 8 with gcc. With gcc lets me compile fortran code along with the C++ program to be able to call the fortran code as a subroutine. The...
8
by: Glenn A. Harlan | last post by:
Why am I receiving the below error when calling - Path.GetTempFileName() The directory name is invalid. Description: An unhandled exception occurred during the execution of the current web...
2
by: yusufjammy | last post by:
How to use mysql in visual basic as database ?
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.