[DllImport("rapi.dll")]
public static extern void CeRapiInitEx(ref RAPIINIT pRapiInit);
HRESULT translates to void (NOT int or anything else some idiot has written down) for c# function prototypes. Any HRESULT other than "OK" will cause the runtime to throw an exception.
function info on msdn at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceactsy/html/cerefCeRapiInitEx.asp
Please add some!
RAPIINIT r = new RAPIINIT();
r.cbsize = Marshal.SizeOf(r);
long ret = CeRapiInitEx(ref r);