Re: ask about CeRapiInvoke in C#



Thank you very much Prter, I am not that familiar with C# ,so my code is not
that logical.Now it has been resolved,the problem rests with the rapi.dll
which is invalid and CeRapiInitEx failed when calling.

Sophia

"Peter Foot [MVP]" <feedback@xxxxxxxxxxxxxxxxxxxx>
??????:D94BC580-C154-4B4A-B907-B290DF9DA570@xxxxxxxxxxxxxxxx
Why are you converting your strings to bytes and back again. Since your
declaration specifies the Unicode charset that is how they will be
marshalled. Also you'll find it easier to pass pcbOutput as out uint
(rather than IntPtr) since this represents the size of ppOutput.

Peter

--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility

"sophia" <lhxsky@xxxxxxx> wrote in message
news:ezEN7hB1HHA.4236@xxxxxxxxxxxxxxxxxxxxxxx
Another point to say is,the self defined dll on wince device works well
when calling in c++,but in c# there is problem.Can you give me some
advice about this ,thank you in advance.

"sophia" <lhxsky@xxxxxxx>
дÈëÏûÏ¢ÐÂÎÅ:O1KIwZB1HHA.536@xxxxxxxxxxxxxxxxxxxxxxx
Hello everyone,

Now I call CeRapiInvoke in C#,but the return value is -2147014795
anyway,can any one give me some clue,thank you in advance. the code
snippet as following:

DllImport("rapi.dll",EntryPoint = "CeRapiInvoke",CharSet =
CharSet.Unicode, CallingConvention = allingConvention.StdCall)]
public static extern Int32 CeRapiInvoke( string pDllPath,
string pFunctionName,
uint cbInput,
byte[] pInput,
out IntPtr pcbOutput,
out IntPtr ppOutput,
IntPtr ppIRAPIStream,//NULL
uint dwReserved
);

uint cbInput = sizeof(byteInputArr);//byteInputArr is byte array defined
before
IntPtr cbOut = IntPtr.Zero;
IntPtr szOut = IntPtr.Zero;
Byte[]input=new Byte[cbInput];//allocate new space to transfer data to
ce
Array.Copy(byteInputArr, 0, input, 0, cbInput);
string path ="mydll.dll";//dll on wince device
string rfname = "rfn";//name of function to call
string upath =
System.Text.Encoding.Unicode.GetString(System.Text.Encoding.Default.GetBytes(path));
string urfname =
System.Text.Encoding.Unicode.GetString(System.Text.Encoding.Default.GetBytes(wfname));

hr = CeRapiInvoke(upath,urfname,cbInput,input,out cbOut,out
szOut,(IntPtr)null,0);






.



Relevant Pages

  • Re: Is C# support load device driver?
    ... how to manage driver loading/unloading using both PInvoke interop and WMI. ... string driverName; ... IntPtr fileHandle; ... databaseName, uint dwDesiredAccess); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: P/Invoking FormatMessage
    ... public static extern int FormatMessage(int dwFlags, IntPtr lpSource, ... int dwMessageId, int dwLanguageId, StringBuilder lpBuffer, int nSize, ... static extern uint FormatMessage(uint dwFlags, IntPtr lpSource, ... public static string GetErrorMessage2 ...
    (microsoft.public.dotnet.framework.compactframework)
  • VirtualAllocEx returns a bad pointer in some processes
    ... (ByVal hWnd As IntPtr, _ ... (ByVal hWndParent As IntPtr, _ ... ByVal lParam As String) As Integer ... Dim aihWnds As ArrayList ...
    (microsoft.public.vc.mfc)
  • Virtual memory C++ problem
    ... (ByVal hWnd As IntPtr, _ ... (ByVal hWndParent As IntPtr, _ ... ByVal lParam As String) As Integer ... Dim aihWnds As ArrayList ...
    (microsoft.public.win32.programmer.kernel)
  • SetPrinter for network printers
    ... Public dmDeviceName As String ... Public pSecurityDescriptor As IntPtr ... Dim pPrinterInfo As IntPtr ...
    (microsoft.public.dotnet.languages.vb)

Loading