Posted: July 29th, 2005, 2:47 pm
Hi there, I am developing some simple learning tools for use in schools to enable the students to use PM3 data as part of their IT Projects. <br /><br />I have written a simple application for recording PM3 data in C but I need to access the data from Visual Basic. I understand that I need to declare the required Dll functions using alias statements but I am having difficulty passing data to and from the SDK Dlls.<br /><br />I seem to be able to get the tkcmdsetDDI_init function to work using the a declare statement. However when I try to call the tkcmdsetDDI_discover_pm3s function I get the following error message and I realise that this is because of the way that I am passing data to and from the dll when calling the function.<br /><br />Run-time error '49':<br /><br />Bad DLL calling function<br /><br />**********************************************************************************<br />PM3DDI_API ERRCODE_T tkcmdsetDDI_discover_pm3s(INT8_T *product_name, <br /> UINT16_T starting_address,<br /> UINT16_T*num_units);<br />**********************************************************************************<br /><br />Here is my code:<br /><br />Option Explicit<br />' Declare the exported functions from the DLL.<br /><br />Private Declare Function Init Lib "RPPM3DDI.dll" _<br /> Alias "tkcmdsetDDI_init" _<br /> () As Integer<br /><br />Private Declare Function Discover_PM3s Lib "RPPM3DDI.dll" _<br /> Alias "tkcmdsetDDI_discover_pm3s" _<br /> (ByVal Product_Name As String, _<br /> ByVal Start_Address As Integer, _<br /> Num_Units As Integer) As Integer<br /> <br />Dim Error_Message As Integer<br />' Dim Start_Address As Integer<br />Dim Num_Units As Integer<br />Dim Product_Name As String<br />'TKCMDSET_PM3_PRODUCT_NAME2 = "Concept2 Performance Monitor 3 (PM3)"<br /> <br />Private Sub Init_Command_Click()<br /> Text7 = 999<br /> Refresh<br /> Error_Message = Init()<br /> If Error_Message = 0 Then<br /> Text1 = "Init 0k!"<br /> Text7 = Error_Message<br /> Else<br /> Text1 = "Init Error!"<br /> Text7 = Error_Message<br /> End If<br /> Refresh<br />End Sub<br /><br />Private Sub Discover_Command_Click()<br /> ' Start_Address = 0<br /> Error_Message = Discover_PM3s(Product_Name, 0, Num_Units)<br />End Sub<br /><br /><br /><br />I would really appreciate any advice. Thanks a lot for any time you can spare. I apologise in advance if I am making very obvious mistakes.<br /><br />Kind Regards Chris