Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem you are having is in the definition of your XcvData definition. The outputData parameter by MS's <a href="http://msdn.microsoft.com/en-us/library/ff564255%28VS.85%29.aspx" rel="nofollow">definition</a> is simply wanting a pointer to write data to, an <em>IntPtr</em> is a pointer, however by setting the parameter to <em>out IntPtr</em> you are making it a pointer to a pointer, this is why the address of your parameter appears to be changing. Changing the signature to the below will fix your problem.</p> <pre><code>[DllImport("winspool.drv", SetLastError = true, CharSet = CharSet.Unicode)] internal static extern int XcvData( IntPtr handle, string dataName, IntPtr inputData, uint inputDataSize, IntPtr outputData, uint outputDataSize, out uint outputNeededSize, out uint status); </code></pre> <p>You can also avoid some unnecessary allocation/deallocation by changing things around a bit.</p> <p>Change your method signature for XcvData to </p> <pre><code>[DllImport("winspool.drv", SetLastError = true, CharSet = CharSet.Unicode)] internal static extern int XcvData( IntPtr handle, string dataName, IntPtr inputData, uint inputDataSize, ref PORT_DATA_1 outputData, uint outputDataSize, out uint outputNeededSize, out uint status); </code></pre> <p>Assuming that you will be using XcvData for more than just this single call you can make multiple references to it with slightly different signatures by setting the EntryPoint property on the DllImport Attribute.</p> <pre><code>[DllImport("winspool.drv", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint="XcvData")] internal static extern int XcvDataGetPortData1( IntPtr handle, string dataName, IntPtr inputData, uint inputDataSize, ref PORT_DATA_1 outputData, uint outputDataSize, out uint outputNeededSize, out uint status); </code></pre> <p>I have given this a quick test on my machine and can confirm that this will fix your problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload