Click here to Skip to main content
15,867,870 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am battling with a DLL to access a USB device that is a HID rather than a Com port(!). I know I can talk to the board using the DLL as I can open the device and reset the Digital outputs on the device using the below code
C#
[DllImport("K8055D.dll")]
public static extern void OpenDevice(int CardAddress);
[DllImport("K8055D.dll")]
public static extern void CloseDevice();
However problems abound when I try to set a Digital Channel. Using the below
C#
private void button2_Click(object sender, EventArgs e)
      {
          SetDigitalChannel(0);
      }
the set digital channel I have imported from the DLL with the following
C#
[DllImport("K8055D.dll")]
       public static extern int SetDigitalChannel(int ChannelAddress);
The (shudder)VB.Net (/shudder) code for this appear to be
C#
Private Declare Sub SetDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer)
So it appears that I can import Functions but not subroutines!
Hmm?

What I have tried:

Importing as [DllImport("K8055D.dll")]
public static extern void OpenDevice(int CardAddress); for functions
similar for importing subroutines
Posted
Updated 25-Feb-16 0:37am

1 solution

It should be like this:

C#
[DllImport("K8055D.dll")]
 public static extern void SetDigitalChannel(int Channel); 


For more details, check this[^] PDF file.
 
Share this answer
 
v4
Comments
glennPattonWork3 25-Feb-16 7:12am    
Great thanks for that, it seems to be importing without but not doing a darn thing, I'll have a fiddle.
glennPattonWork3 25-Feb-16 7:24am    
Mmm, It is producing a run time error 217 00009C34 a new one on me! lets have a google...
glennPattonWork3 25-Feb-16 7:29am    
Ahh if the thing is running under VSHost!
glennPattonWork3 25-Feb-16 7:43am    
Got it working!
dan!sh 25-Feb-16 23:11pm    
Great! I had left by the time you responded. Came back online this morning, only to see 12 notifications (that's a lot for me).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900