Re: Question on Marshaling

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Alex Feinman [MVP] (public_news_at_alexfeinman.com)
Date: 04/08/04


Date: Thu, 8 Apr 2004 00:19:46 -0700

Change the PInvoke definition to:

DllImport("Coredll.dll", SetLastError=true)]
public static extern bool ReadMsgQueue(
int hMsgQ,
byte[] lpBuffer,
int cbBufferLen,
out int lpNumberOfBytesRead,
int dwTimeout,
out int dwFlags ) ;

Adjust your parameters accordingly.

-- 
Alex Feinman
---
Visit http://www.opennetcf.org
"Rodger Higgins" <rhiggins@earthling.net> wrote in message
news:O$myyTJHEHA.740@tk2msftngp13.phx.gbl...
> I am trying marshal ReadMSgQueue on a Windows CE .NET platform.  I am
> using the following code:
>
>
> ...
> [DllImport("Coredll.dll", SetLastError=true)]
> public static extern bool ReadMsgQueue(
> int hMsgQ,
> out byte[] lpBuffer,
> int cbBufferLen,
> out byte[] lpNumberOfBytesRead,
> int dwTimeout,
> out byte[] dwFlags ) ;
> ...
>
> if ( !MsgQueue.ReadMsgQueue( hReadMsgQueue, out msg, 64, len, 0, flags ) )
> {
> MessageBox.Show( "Err: " + MsgQueue.GetLastError() ) ;
> }
> else
> {
> Received.Items.Add( "OK" ) ;
> UnicodeEncoding UEncoder = new UnicodeEncoding() ;
> string msgString = UEncoder.GetString( msg, 0, msg.Length ) ;
>
> MessageBox.Show( msgString ) ;
> }
>
>
> The Received.Items.Add causes a general exception if its located after
> the call to ReadMsgQueue.   It appears to be related to marshaling the
> lpBuffer parameter.  What am I missing or doing wrong?
>
> Thanks
> Rodger Higgins


Relevant Pages

  • Re: UNC-Pfad aus LogicalDrive
    ... private static extern int WNetGetUniversalName(string lpLocalPath, ... int dwInfoLevel, ref UNIVERSAL_NAME_INFO lpBuffer, ref int ... int nRet = WNetGetUniversalName( ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: GetIpNetTable
    ... Nicholas Paldino [.NET/C# MVP] ... > public static extern int GetIpNetTable; ... > lpBuffer = Marshal.AllocHGlobal;> ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: WNetCancelConnection2 failure
    ... public string usri1003_password; ... public int dwScope; ... // Add an IPC$ connection to the remote host ...
    (microsoft.public.dotnet.general)
  • Re: Getting Path To Recycle Bin
    ... int CSIDL_BITBUCKET = 0x000a; ... StringBuilder pszPath = new StringBuilderJConst.MAX_PATH); ... public static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, StringBuilder pszPath); ...
    (microsoft.public.dotnet.languages.csharp)
  • GetIpNetTable
    ... Marshalling and could really do with some help - it's late and I am tired - ... public static extern int GetIpNetTable(IntPtr buffer,ref int Size, bool ... lpBuffer = Marshal.AllocHGlobal; ... // But canot allocate the structures from here - I hope someone out there ...
    (microsoft.public.dotnet.languages.csharp)