473,320 Members | 1,951 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,320 software developers and data experts.

usnig C++ dll from VB.NET

TF
Hi,
I am using C++ dll (dynamic-linked library, not COM ATL) in my VB.NET
program. when i pass a VB.Net 'String' object to one of the function
of dll that modifies the string, it works fine. dll code is like:

long UpdateString(LPWSTR str)
{
wcscpy( str, L"result" );

return wcslen( str );
}

and function declaration in VB is like:

<DllImport("TestDllEx.dll", EntryPoint:="UpdateString",_
SetLastError:=True, _
CharSet:=CharSet.Unicode, ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function _
UpdateStringA(ByVal str As String) As Integer
End Function

Now the problem is when i pass a VB Structure that has an 'Integer'
and a 'String' member to dll function to modify, it only copies one
character to the String member whereas Integer member is modified
successfully. dll structure & function are like:

struct myst
{
long x;
LPWSTR s;
};

long UpdateStruct(myst *st)
{
st->x = 100;
wcscpy( st->s, L"result" );

return wcslen( st->s );
}
in VB.Net they are like:

Public Structure myst
Dim x As Integer
Dim s As String
End Structure

<DllImport("TestDllEx.dll", EntryPoint:="UpdateStruct",_
SetLastError:=True, _
CharSet:=CharSet.Unicode, ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function _
UpdateStructA(ByRef st As myst) As Integer
End Function

The function returns correct size i.e. 6 (length of string "result").
But in VB i get only "r" in the string member.
Can anyone help??

Thanks
Nov 22 '05 #1
0 1055

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

Similar topics

19
by: dcrespo | last post by:
Hi all... Is there a way to print a PDF file directly from Python without having Acrobat installed? I know about ReportLab. It's a python module that lets you create almost any PDF document, but I...
0
by: amine | last post by:
I really need help on this please. I am writing an application for an Ipaq and I am trying to enable the application to connect to a DAV server which can is basically an HTTP server that acts like...
3
by: Savas Ates | last post by:
<form action="a.asp" method="get" > <input type="image" border="0" src="IMAGES/oklar.jpg"> </form> im usnig this codes to submit form when a user click on oklar.jpg(an image)
0
by: TF | last post by:
Hi, I am using C++ dll (dynamic-linked library, not COM ATL) in my VB.NET program. when i pass a VB.Net 'String' object to one of the function of dll that modifies the string, it works fine. dll...
30
by: Neil Zanella | last post by:
Hello, Suppose I have some method: Foo::foo() { static int x; int y; /* ... */ }
9
by: David Poundall | last post by:
I have a thread class and I want to be able to track its usage within an application. FYI the class launches aplications in their own thread when the 'launch' method is called. That works OK ...
3
by: Hasanain F. Esmail | last post by:
Hi, Your help will be greatly appriciated. I have a table with following fields. Table's name is tblTicketNumers TicketNumberID (It is a key field) TicketNumber (Text field) AgentsName (Text...
1
by: Paul Moore | last post by:
Is there a convenient way to ignore the Insert, Delete, and keyboard navigation keys when using bound forms?
2
by: vssp | last post by:
Hai fiends I want to disable the righ click option in my web application. How to hide the right click option usong php? Please send me any idea.
0
by: sugarboy | last post by:
Hi, Can u let me know how to construct an XML using XML twig in perl. Also can u help in finding good notes on XML twig. Thanks, Sugarboy
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.