DeviceID code - doesn't work

  • Thread starter Thread starter Nathan
  • Start date Start date
N

Nathan

It returns false with Marshal.GetLastWin32Error() returning 0. (not
ERROR_INSUFFICIENT_BUFFER)

This is on my device, which works if I start out with a larger buffer 9say
256). I was trying this code to get around devices that don't like the
buffer to be too large. But this isn't helpful.

Any other code I should try?

Nathan
 
Is anything written to the buffer at all? sometimes the required size is
written into the first 4 bytes

Peter
 
I think that's what was happening.

The outcoming size was 4 bytes.

However it was returning 0 as last error, not INSUFFICIENT_BUFFER, so the
code was breaking.

I found out if you pass in exactly 16 bytes, it succeeds and returns exactly
16 bytes. But if you pass in 20, it fails with an unexpected error message.

I tried starting out with a buffer of 1024, and dropping back to a 16 byte
buffer if that fails. In that case, I have to extract the number differently
than what was in the code.

It started working for one customer, but I have no way of knowing which code
path was successful and whether the buffer was too small or too big. I hope
it works for other customers.

Nathan
 
Back
Top