microTone Module example programs are located at \samples directory.
Recommended code layout for static DLL interface (this example based on Lazarus/Delphi):
// 1. load functions from DLL. function UTMCreatePacket(OutData : Byte) : Word; stdcall; external 'utm.dll'; function UTMCreateBytePacket(OutData: Byte): Word; stdcall; external 'utm.dll'; . . . // 2. Reset the device using 0x9 command. (optional) if UTMCreatePacket(9) = 0) then begin . . . // 3. Send command to device. if UTMCreateBytePacket(255) = 0 then . . . end;
Recommended code layout for dynamic DLL interface (this example is based on C++):
// 1. Load DLL into the application. HINSTANCE hDLL = LoadLibrary(L"utm.dll"); . . . // 2. Load function from DLL. typedef short (__stdcall *sendP)(char); typedef short (__stdcall *sendByteP)(char); sendP _send; sendByteP _sendByte; if(hDLL) { _send = (sendP)GetProcAddress(hDLL, "UTMCreatePacket"); _sendByte = (sendByteP)GetProcAddress(hDLL, "UTMCreateBytePacket"); . . . // 3. Reset the device using 0x9 command. (optional) if(_send(9) == 0) { . . . // 4. Send command to device. if(_sendByte(255) == 0) { ... } . . . } . . . // 5. Close DLL handle. CloseHandle(hDLL); }