C# to VB

N

Nikolay Petrov

Hi guys
I have some sample code from MSDN which is in C#
I need it badly in VB.
I've tried some C# to VB convertor but they didn't do the job.

The code is just a few Win API functions definitions.

Could someone make the convertion for me.
Thanks in advance.

CODE:

[DllImport("Crypt32.dll", SetLastError=true,
CharSet=System.Runtime.InteropServices.CharSet.Auto)]
private static extern bool CryptProtectData(
ref DATA_BLOB pDataIn,
String szDataDescr,
ref DATA_BLOB pOptionalEntropy,
IntPtr pvReserved,
ref CRYPTPROTECT_PROMPTSTRUCT
pPromptStruct,
int dwFlags,
ref DATA_BLOB pDataOut);
[DllImport("Crypt32.dll", SetLastError=true,
CharSet=System.Runtime.InteropServices.CharSet.Auto)]
private static extern bool CryptUnprotectData(
ref DATA_BLOB pDataIn,
String szDataDescr,
ref DATA_BLOB pOptionalEntropy,
IntPtr pvReserved,
ref CRYPTPROTECT_PROMPTSTRUCT
pPromptStruct,
int dwFlags,
ref DATA_BLOB pDataOut);
[DllImport("kernel32.dll",
CharSet=System.Runtime.InteropServices.CharSet.Auto)]
private unsafe static extern int FormatMessage(int dwFlags,
ref IntPtr lpSource,
int dwMessageId,
int dwLanguageId,
ref String lpBuffer,
int nSize,
IntPtr *Arguments);
 
O

One Handed Man \( OHM - Terry Burns \)

Along the following lines, but your types need to be defined IE DATA_BLOB
and CRYPTPROTECT_PROMPTSTRUCT etc

private declare function CryptProtectData lib "Crypt32.dll" Alias
"CryptProtectDataA"( _

pDataIn as DATA_BLOB , _

szDataDescr as String , _

pOptionalEntropy as DATA_BLOB , _

pvReserved as IntPtr ,

pPromptStruct as CRYPTPROTECT_PROMPTSTRUCT, _

dwFlags as int , _

pDataOut as DATA_BLOB )_


--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
 
H

Herfried K. Wagner [MVP]

One Handed Man ( OHM - Terry Burns ) said:
Along the following lines, but your types need to be defined IE DATA_BLOB
and CRYPTPROTECT_PROMPTSTRUCT etc

private declare function CryptProtectData lib "Crypt32.dll" Alias
"CryptProtectDataA"( _

pDataIn as DATA_BLOB , _

Should be 'ByRef'.
szDataDescr as String , _

pOptionalEntropy as DATA_BLOB , _
Dito.

pvReserved as IntPtr ,

pPromptStruct as CRYPTPROTECT_PROMPTSTRUCT, _
Dito.

dwFlags as int , _

'int' -> 'Int32'.
pDataOut as DATA_BLOB

'ByRef'.
 
O

One Handed Man \( OHM - Terry Burns \)

I said

"Along the following lines"

OHM

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top