Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing DLL - Issues with .net or VB dll

Status
Not open for further replies.

steve4king

IS-IT--Management
Feb 6, 2007
154
0
0
US
I'm trying to access a MagTek library to control some hardware. (IPADLib.dll / MTIPADlib.dll)
MagTek has also included MYIPADLib.h and MTIPADLib.lib. (The MT..dlls are used for VC/VB)

I found a .tlb in some sample code which loaded into the Fox object browser, so Intellisense is working. However, I'm unable to create an olecontrol class from any of the DLLs. Attempting to do so results in an Error box with no dialog.

Code:
LOCAL ctlIPAD as "IPADLib.IPAD"
ctlIPAD = CREATEOBJECTEX("IPADLIB.IPAD","","")
ctlIPAD.RequestSig(50,1)

This code results in "Class not Registered".
I originally attempted to register a library with regsvr32, after that failed, I used regasm which returned, "Type registered successfully". Despite this, Fox still complains that it is not registered.

Do I need to create my own wrapper in C# with the correct exposure?
Can I use the MT...Dlls with simpler declare instead?

Thanks,



-Stephen
 
They don't appear to have an OCX for the MagTek IPAD unfortunately.
(terrible name "IPAD", for something that has nothing to do with Apple's tablet)

-Stephen
 
Well, I decided to play with the less pretty MTIPADLIB.DLL to see whether this would work any better.
Not too much luck here either..

The call results in 5, even if I use a bogus class name.
I tried declaring as both "MTIPADLIB_API.MTIPADRequestSig" and just "MTIPADRequestSig". But since the result is the same if I use "Bogus", I'm guessing I'm calling this wrong still.


My Code:
Code:
PROCEDURE ipad
	LOCAL something as Integer, lcBuffer1, lcBuffer2, lcBuffer3, lcBuffer4
	
	**args 1,2,4 are Bytes, but BYTE is not available for DLL declarations, arg 3 is a structure containing a byte and an integer
	DECLARE integer MTIPADLIB_API.MTIPADRequestSig IN F:\Work\MBZ.153\Libs\MTIPADLIB.dll ;
	  String bOne, String bTwo, String @ objThree, String @ bFour
	
	something = 0
	lcBuffer1 = Repli(Chr(1), 1)	&& byte
	lcBuffer2 = Repli(Chr(1), 1) 	&& byte
	lcBuffer3 = Repli(Chr(0), 7169) && byte[7168] + int as Reference
	lcBuffer4 = Repli(Chr(0), 1) 	&& byte as reference
	
	something = MTIPADRequestSig(lcBuffer1, lcBuffer2, @lcBuffer3, @lcBuffer4) 
	?something && results in 5
	
ENDPROC

MTIPADLIB.H
Code:
#ifdef MTIPADLIB_EXPORTS
#define MTIPADLIB_API __declspec(dllexport)
#else
#define MTIPADLIB_API __declspec(dllimport)
#endif
#include <iostream>
#include <string>
using namespace std;

#define MAX_SIGDATA_LENGTH 7168

typedef struct _SIG_DATA
{
	BYTE *Data;
	int Sig_Length;
}SIG_DATA;


MTIPADLIB_API int _stdcall MTIPADRequestSig(BYTE waitTime, BYTE tones, SIG_DATA* pData, BYTE *opStatus);


VC Sample
Code:
m_SigData.Data = new BYTE[MAX_SIGDATA_LENGTH];
retCode = MTIPADRequestSig(waitTime, tone, &m_SigData, &opStatus)


Any pointers?
Thanks!

-Stephen
 
Bahh.. Fox wasn't attempting to reload the class each time I altered the code.

It does recognize an invalid class name, thus it IS finding the function when I call it with:
DECLARE integer MTIPADRequestSig.

Probably not a code problem here, I'm guessing I just need to call a few things to initialize the device first.
I'll update when I get that figured out.

-Stephen
 
Hah,
It worked fine.

Thanks y'all for being my sounding board, hopefully this long-winded post will be useful to someone else down the road.

:)

-Stephen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top