473,405 Members | 2,334 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,405 software developers and data experts.

Need to call C++ function from VB.NET

The function is declared as :
void WINAPI AIEncrypt( LPSTR sReadable, LPSTR sEncrypted )

What is the correct way to declare the function in VB.NET, and then what is
the right way to call it? The function encrypts the first string, and stores
the encrypted version in the second parameter.
Nov 21 '05 #1
2 1114
Hi Marina,

Probably it will be

~
Declare Ansi Sub AIEncrypt Lib "your.dll" (<MarshalAs(UnmanagedType.LPStr)>
ByVal sReadable As String, <MarshalAs(UnmanagedType.LPStr)> ByVal sEncrypted
As String)

....

Dim Result As New String(Chr(0), 256) REM you may need to change 256 to
appropriate buffer size
AIEncrypt("Some String", Result)
~

Maybe you'll have to put something like ~Alias "AIEncryptA"~ in your
declare.

I hope this helps.

Roman

"Marina" <so*****@nospam.com> сообщил/сообщила в новостях следующее:
news:#N**************@TK2MSFTNGP14.phx.gbl...
The function is declared as :
void WINAPI AIEncrypt( LPSTR sReadable, LPSTR sEncrypted )

What is the correct way to declare the function in VB.NET, and then what is the right way to call it? The function encrypts the first string, and stores the encrypted version in the second parameter.

Nov 21 '05 #2
Thanks.

So, we've been able to get this to work in a VB.NET windows app, but not in
a web application. The code is the same. We've tried making the ASP.NET user
an admin

The function just does some encryption. It's failing silently with the same
input, and the return string is empty, instead of having the encrypted
value.

Any ideas on why this would happen?

"Dragon" <no@spam.please> wrote in message
news:eN**************@TK2MSFTNGP12.phx.gbl...
Hi Marina,

Probably it will be

~
Declare Ansi Sub AIEncrypt Lib "your.dll"
(<MarshalAs(UnmanagedType.LPStr)>
ByVal sReadable As String, <MarshalAs(UnmanagedType.LPStr)> ByVal
sEncrypted
As String)

...

Dim Result As New String(Chr(0), 256) REM you may need to change 256 to
appropriate buffer size
AIEncrypt("Some String", Result)
~

Maybe you'll have to put something like ~Alias "AIEncryptA"~ in your
declare.

I hope this helps.

Roman

"Marina" <so*****@nospam.com> сообщил/сообщила в новостях следующее:
news:#N**************@TK2MSFTNGP14.phx.gbl...
The function is declared as :
void WINAPI AIEncrypt( LPSTR sReadable, LPSTR sEncrypted )

What is the correct way to declare the function in VB.NET, and then what

is
the right way to call it? The function encrypts the first string, and

stores
the encrypted version in the second parameter.


Nov 21 '05 #3

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

Similar topics

6
by: R.Wieser | last post by:
Hello All, I'm trying to get a "Virtual Listbox" to work. I've currently got a form, and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and LBS_NODATA flags on it. I've...
45
by: Joh | last post by:
hello, i'm trying to understand how i could build following consecutive sets from a root one using generator : l = would like to produce : , , , ,
9
by: Bill Borg | last post by:
Hello, I call a function recursively to find an item that exists *anywhere* down the chain. Let's say I find it five layers deep. Now I've got what I need and want to break out of that whole...
18
by: bsruth | last post by:
I tried for an hour to find some reference to concrete information on why this particular inheritance implementation is a bad idea, but couldn't. So I'm sorry if this has been answered before....
4
by: =?Utf-8?B?UHVjY2E=?= | last post by:
The function that I'm trying to call through DLLImport has a parameter that has a C code's vector's Itrator to a structure. I Have marshalled the structure in C# but how do I do the C type...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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.