473,396 Members | 2,109 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.

Translate from C/C++ to VB.net


Please could someone translate this for me from C/C++ to VB.net?

#define MY_CONST 1

typedef struct _MYSTRUCT {
const char* p1;
int p2;
char p3[20];
short p4;
unsigned long p5;
} MYSTRUCT;

void main()
{
HINSTANCE someDLL = LoadLibrary("some.dll");

MYSTRUCT prop;
prop.p1 = "some text";
prop.p2 = 2;
prop.p4 = 8;
prop.p5 = 10;

MYSTRUCT (*fnMyFunc)(MYSTRUCT);
fnMyFunc=(MYSTRUCT (*)(MYSTRUCT)) GetProcAddress(someDLL,"myFunc");
MYSTRUCT result = fnMyFunc(prop);
}

Thank you in advance.

Nov 21 '05 #1
3 4615

At least, could you please tell me how can I translate:

char a[20]

and

unsigned int i?
Nov 21 '05 #2

Is this a proper translation?

Private Const MY_CONST = 1

<StructLayout(LayoutKind.Sequential)> Public Structure MYSTRUCT
Public p1 As String
Public p2 As Integer
<MarshalAs(UnmanagedType.ByValTStr, sizeconst:=20)> Public p3 As String
Public p4 As Short
Public p5 As Integer
End Structure

Private Declare Function myFunc Lib "some" (ByVal prop As MY_STRUCT) As
MY_STRUCT

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim prop As MY_STRUCT
Dim res As MY_STRUCT

prop.p1 = "some text..."

res = myFunc(prop)
End Sub
Nov 21 '05 #3

This is outside my area of expertise, so I'm asking, not declaring.
However, wouldn't 'Private Const MY_CONST = 1' be better written as
'#Const MY_CONST = 1' instead? Also, wouldn't P5 be better declared as
UInt64 rather than Integer?
Thanx,
Ralf
"Petar Popara" <my*****@mail.net> wrote in message
news:OD**************@TK2MSFTNGP10.phx.gbl...
:
: Is this a proper translation?
:
: Private Const MY_CONST = 1
:
: <StructLayout(LayoutKind.Sequential)> Public Structure MYSTRUCT
: Public p1 As String
: Public p2 As Integer
: <MarshalAs(UnmanagedType.ByValTStr, sizeconst:=20)> Public p3 As
: String
: Public p4 As Short
: Public p5 As Integer
: End Structure
:
: Private Declare Function myFunc Lib "some" (ByVal prop As MY_STRUCT)
: As MY_STRUCT
:
: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
: System.EventArgs) Handles MyBase.Load
: Dim prop As MY_STRUCT
: Dim res As MY_STRUCT
:
: prop.p1 = "some text..."
:
: res = myFunc(prop)
: End Sub
:
:


Nov 21 '05 #4

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

Similar topics

7
by: Bengt Richter | last post by:
Just thought None as the first argument would be both handy and mnemonic, signifying no translation, but allowing easy expression of deleting characters, e.g., s = s.translate(None,...
1
by: shank | last post by:
I'm sure this is a stretch, but is there some kind of component that I could install to translate from English to Spanish on the fly? I have a lot of equipment features and specifications that I...
4
by: Gadrin77 | last post by:
I have data that looks like <Root> <Main Value="Line1|Line2.|Line3|Line4.|Line5"/> </Root> I'm using Translate(@Value, "|.", ",")
6
by: bobueland | last post by:
The module string has a function called translate. I tried to find the source code for that function. In: C:\Python24\Lib there is one file called string.py I open it and it says
6
by: Anders K. Olsen | last post by:
Hello group I'm trying to list the users and groups who has read access to a file. I use .NET 2.0 and FileInfo.GetAccessControl().GetAccessRules(...) and then loop through the...
1
by: peterbe | last post by:
This has always worked fine for me. Peter fine Now if I do it with a unicode string: Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/string.py", line...
9
bvdet
by: bvdet | last post by:
I have done some more work on a simple class I wrote to calculate a global coordinate in 3D given a local coordinate: ## Basis3D.py Version 1.02 (module macrolib.Basis3D) ## Copyright (c) 2006...
1
by: =?Utf-8?B?R2F1cmF2?= | last post by:
Hi, I am using the Translate() function in one of the .XSLT file to remove the spaces, like this: <xsl:for-each select=".//Illustration"> <xsl:value-of select="translate(./@illusName, ' ',...
3
by: Kenneth McDonald | last post by:
I have the need to occasionally translate a single word programatically. Would anyone have a Python script that would let me do this using Google (or another) translation service? Thanks, Ken
4
by: kovariadam | last post by:
Hi, Does anybody know why i get this error: SQL0176N The second, third or fourth argument of the TRANSLATE scalar function is incorrect. SQLSTATE=42815 with this query: SELECT...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.