[Moderator's note: Moved topic from Bug Reports to Ask for Help.]
Windows 7 Ultimate (64-bit)
AutoHotkey_L v1.0.92.02 Unicode (32-bit)
I am trying to call functions from the
gtvremote.dll (
GoTView Remote Control SDK).
Code:
Exported Functions List
Created by using DLL Export Viewer http://www.nirsoft.net/utils/dll_export_viewer.html
┌───────────────────────────────────────────────────────────────────────────────────────┬────────────┬────────────┬─────────┬───────────────┐
│ Function Name │ Address │ Relative │ Ordinal │ Filename │
├───────────────────────────────────────────────────────────────────────────────────────┼────────────┼────────────┼─────────┼───────────────┤
│ public: __thiscall CGTVRemote::CGTVRemote(void) │ 0x10001145 │ 0x00001145 │ 1 (0x1) │ gtvremote.dll │
│ public: __thiscall CGTVRemote::~CGTVRemote(void) │ 0x100011a2 │ 0x000011a2 │ 2 (0x2) │ gtvremote.dll │
│ public: class CGTVRemote & __thiscall CGTVRemote::operator=(class CGTVRemote const &) │ 0x10001000 │ 0x00001000 │ 3 (0x3) │ gtvremote.dll │
│ public: long __thiscall CGTVRemote::GetCode(unsigned char *) │ 0x100011c3 │ 0x000011c3 │ 4 (0x4) │ gtvremote.dll │
│ public: char * __thiscall CGTVRemote::GetDeviceName(unsigned long) │ 0x100011e2 │ 0x000011e2 │ 5 (0x5) │ gtvremote.dll │
│ public: long __thiscall CGTVRemote::SelectDevice(unsigned long) │ 0x10001200 │ 0x00001200 │ 6 (0x6) │ gtvremote.dll │
└───────────────────────────────────────────────────────────────────────────────────────┴────────────┴────────────┴─────────┴───────────────┘
Here is my script (partially working).
Calling to SelectDevice is commented out because AutoHotkey_L crashes on it.
Other functions seems to work fine.
Code:
#NoEnv
#SingleInstance Force
SetWorkingDir, %A_ScriptDir%
SetBatchLines, -1
OnExit, ExitSub
Gui, Font, , Consolas
Gui, Add, Text, vStatic1, Capture Devices (0):
Gui, Add, ListView, vListView1, Index|Device
Gui, Add, Text, vStatic2, Remote Codes:
Gui, Add, ListView, vListView2, Elapsed|Code
Gui, Add, StatusBar
Gui, Show, , GoTView RC
Menu, Tray, Tip, GoTView RC
IfNotExist, gtvremote.dll, UrlDownloadToFile, http://www.autohotkey.net/~Big_Digger/GoTView/gtvremote.dll, gtvremote.dll
if !hModule := DllCall("GetModuleHandle", "Str", "gtvremote", "Ptr")
hModule := DllCall("LoadLibrary", "Str", "gtvremote", "Ptr")
pCGTVRemote := DllCall("GetProcAddress", "Ptr", hModule, "UInt", 1, "Ptr")
pGetDeviceName := DllCall("GetProcAddress", "Ptr", hModule, "UInt", 5, "Ptr")
pSelectDevice := DllCall("GetProcAddress", "Ptr", hModule, "UInt", 6, "Ptr")
pGetCode := DllCall("GetProcAddress", "Ptr", hModule, "UInt", 4, "Ptr")
pRemote := DllCall(pCGTVRemote, "Ptr")
Loop
{
if !DeviceName := DllCall(pGetDeviceName, "UInt", A_Index - 1, "AStr")
Break
GuiControl, , Static1, Capture Devices (%A_Index%):
Gui, ListView, ListView1
LV_Add("", A_Index - 1, DeviceName)
if InStr(DeviceName, "GOTVIEW")
{
; Result := DllCall(pSelectDevice, "UInt", A_Index - 1, "Int")
if (Result = 0)
{
LV_Modify(A_Index, "Select")
SetTimer, TimerSub, 50
}
}
}
Return
TimerSub:
Result := DllCall(pGetCode, "UChar*", RemoteCode, "Int")
if (Result = 0 and RemoteCode < 255)
{
Elapsed := A_TickCount - PrevCount, PrevCount := A_TickCount
Gui, ListView, ListView2
RowNumber := LV_Add("", Elapsed, RemoteCode)
LV_Modify(RowNumber, "Vis")
}
Return
ExitSub:
GuiClose:
if hModule := DllCall("GetModuleHandle", "Str", "gtvremote", "Ptr")
DllCall("FreeLibrary", "Ptr", hModule)
ExitApp
gtvremote.hCode:
#ifdef GTVREMOTE_EXPORTS
#define GTVREMOTE_API __declspec(dllexport)
#else
#define GTVREMOTE_API __declspec(dllimport)
#endif
// This class is exported from the gtvremote.dll
// Supported TV tuners:
// 1 - GoTView PCI (Conexant driver)
// 2 - GoTView PCI (Gotview driver)
// 3 - GoTView PCI 7134
// 4 - GoTView PCI 7135
// 5 - GoTView PCI DVD (IVAC15 driver)
// 6 - GoTView PCI DVD (Falcon2 driver)
// 7 - GoTView PCI DVD3
// 8 - GoTView PCI HYBRID
typedef enum CARD_TYPE
{
CARD_UNKNOWN=0,
CARD_878_CX=1,
CARD_878_GT=2,
CARD_7134=3,
CARD_7135=4,
//Cards with a similar remote control
CARD_DVD_IVAC=5,
CARD_DVD_FALCON=6,
CARD_DVD_RAPTOR=7,
CARD_CXVASVID=8,
// GoTView PCI 713X with BDA driver
CARD_713X_BDA=9
//
}CARD_TYPE;
class GTVREMOTE_API CGTVRemote
{
public:
CGTVRemote(void);
~CGTVRemote(void);
// dwCode receives a code of the pressed button, if any; otherwise, the value is 0xFF.
// If the function succeeds, the return value is 0 (S_OK). Otherwise, it returns an HRESULT error code.
HRESULT GetCode(BYTE* dwCode);
// Returns a name of the capture device. Otherwise, returns NULL (if devnum+1 greater than number of devices in the system);
LPSTR GetDeviceName(DWORD devnum);
// Selects a capture device. If the function succeeds, the return value is 0 (S_OK). Otherwise, it returns an HRESULT error code.
HRESULT SelectDevice(DWORD devnum);
// Cards based on the bt878 chip (GoTView PCI) been 2 modifications of the RC controllers. If the left and right buttons do not works, m_bChipTypeTM must be set to true;
// Does not affects other cards.
BOOL m_bChipTypeTM;
CARD_TYPE m_cCardType;
};
gtvremotetest.cppCode:
// gtvremotetest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "gtvremotetest.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "gtvremote.h"
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
CGTVRemote* Remote=new CGTVRemote;
LPSTR pszDevname=NULL;
DWORD num=0;
do
{
pszDevname=Remote->GetDeviceName(num);
if(pszDevname)
{
printf("%s\n",pszDevname);
char *ptr;
for (ptr = pszDevname; *ptr; ptr++)*ptr = toupper( *ptr );
if(strstr(pszDevname,"GOTVIEW"))break;
}
num++;
}while(pszDevname);
Remote->SelectDevice(num);
Remote->m_bChipTypeTM=false;
switch (Remote->m_cCardType)
{
case CARD_878_CX: {printf("CardType CARD_878_CX\n"); break;}
case CARD_878_GT: {printf("CardType CARD_878_GT\n"); break;}
case CARD_7134: {printf("CardType CARD_7134\n"); break;}
case CARD_7135: {printf("CardType CARD_7135\n"); break;}
case CARD_DVD_IVAC: {printf("CardType CARD_DVD_IVAC\n");break;}
case CARD_DVD_FALCON: {printf("CardType CARD_DVD_FALCON\n");break;}
case CARD_DVD_RAPTOR: {printf("CardType CARD_DVD_RAPTOR\n");break;}
case CARD_CXVASVID: {printf("CardType CARD_CXVASVID\n");break;}
case CARD_713X_BDA: {printf("CardType CARD_713X_BDA\n");break;}
case CARD_UNKNOWN:
default : {printf("CardType CARD_UNKNOWN\n");break;}
}
while(true)
{
BYTE bCode=0xFF;
Remote->GetCode(&bCode);
if(bCode!=0xFF)printf("Code=%d\n",bCode);
Sleep(50);
}
return nRetCode;
}