tags:

views:

294

answers:

1

Hi,

I have successfully hooked a dll function in c#

[DllImport ("ftusbsrv.dll", EntryPoint="FtEnumDevices")]
public unsafe static extern bool FtEnumDevices(ref FT_SERVER_USB_DEVICE lpUsbDevices, ref ulong pulBufferSize, ref FT_ERROR_STATE lpES);

I need to pass null as as first parameter as below

FtEnumDevices(null, pulBufferSize,lpES);

I am getting the following compile time error:

Argument '1': cannot convert from '' to 'ref FebulaTechWrapper.USBOverNetWrapper.FT_SERVER_USB_DEVICE'

I need to know: How can I pass null as a first parameter?

+3  A: 

I don't think that null is your problem - it seems like lpEs is an int in your code but ftusbsrv.dll is expecting a type of FebulaTechWrapper.USBOverNetWrapper.FT_ERROR_STATE.

You will need to recreate FT_ERROR_STATE in your C# code so that you can pass an instance to the method instead of an int.

Edit: You cannot pass null to a method that expects a ref argument. A ref argument needs a reference, try something like this:

FT_SERVER_USB_DEVICE dummy = null;

FtEnumDevices(ref dummy, pulBufferSize, lpES);
Andrew Hare
sorry the error wasnt posted correct Argument '1': cannot convert from '' to 'ref FebulaTechWrapper.USBOverNetWrapper.FT_SERVER_USB_DEVICE'
Abdul Khaliq