By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,586 Members | 1,051 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,586 IT Pros & Developers. It's quick & easy.

Need to call C++ function from VB.NET

P: n/a
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
Share this Question
Share on Google+
2 Replies

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.