PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Determine Irda COM port

I need to determine which COM port Irda is bound to at run-time. I found the following piece of code:
Code:

// Look into the registry for the IR port number

HKEY hKey = NULL;

if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Comm\\IrDA"),
0, 0, &hKey;) == ERROR_SUCCESS)
{
DWORD dwType = 0;
DWORD dwData = 0;
DWORD dwSize = sizeof(dwData);

if (RegQueryValueEx(hKey, _T("Port"), NULL, &dwType;,
(LPBYTE) &dwData;, &dwSize;) == ERROR_SUCCESS)
{
if (dwType == REG_DWORD && dwSize == sizeof(dwData))
{
RegCloseKey(hKey);

return (UINT) dwData;
}
}

RegCloseKey(hKey);
}

return 0;

(http://www.codeproject.com/ce/TVRemote.asp)

However there is no such registry entry on my a716. There is a HKEY_LOCAL_MACHINE\Comm\IrDA key, but it does not contain a Port value.

Any suggestions?

Dan East
After searching the registry, it appears the proper key is HKEY_LOCAL_MACHINE/Drivers/BuiltIn/IrDA/Index.

At least that works for my iPaq 3630 and Asus a716 which have Irda on COM2.

Dan East
It also works on the a620, which has Irda on [edit]COM4 (not COM3)[/edit], so I'm fairly confident of this technique.

Dan East
You might want to check for both, just in case?
Pejo Software - Per · 11 Oct 2004, 07:19 UTC
I would say that this is quite safe. The Device Manager uses these keys to load the driver at start-up. It is however possible to load/unload a driver with RegisterDevice/DeregisterDevice.
Dan,

This is what we've been using for years for irda communications to printers and we've never had an issue. Here is the code snipit:

Code:
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
TEXT("Drivers\\Builtin\\IrCOMM"), 0, 0, &hKey) == ERROR_SUCCESS)
{
dwSize = sizeof(dwData);
if(RegQueryValueEx(hKey, TEXT("Index"), 0, &dwType, (PBYTE)&dwData, &dwSize)==ERROR_SUCCESS)
{
if(dwData < 10)
wsprintf(pDevName, TEXT("COM%d:"), dwData);


What'cha communicating with? Your joystick?
Thanks, but I have to use Irda, and IrCOMM is higher-level. I need lower level access to the raw data.

Yep, it's for my PSX driver. I had hardcoded the port for my a716, so I had to do it the right way since the port is different on a beta tester's device.

Dan East
Ahhh got'cha. Then I would say that you have the right one:

HKEY_LOCAL_MACHINE/Drivers/BuiltIn/IrDA/Index

If you need any help, let me know.