I want to use the function CryptProtectData()

the definition is:

[DllImport("Crypt32.dll",SetLastError = true,CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool CryptProtectData(
ref DATA_BLOB pDataIn,
String szDataDescr,
ref DATA_BLOB pOptionalEntropy,
IntPtr pvReserved,
ref CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
CryptProtectFlags dwFlags,
ref DATA_BLOB pDataOut
);

the parameter "CRYPTPROTECT_PROMPTSTRUCT pPromptStruct" requires a ref to structure, but i need to pass null here. the description of the function on msdn says that u can pass null here, but C# doesnot allow this...

Is there any way out... plz help...

Why not just use ProtectedData class from .NET? They do the exact same thing.

Otherwise you can declare in your C# code that CRYPTPROTECT_PROMPTSTRUCT is a class and pass null.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.