I happened to have a bit of code lying around that enumerates the mice attached to the system. If there's more than one, it's likely that one is a trackpad and the other one an external mouse, although I guess it might be a trackpad and one of those little sticks. It should be possible to use the same API to get enough information about each nominal mouse to make an intelligent guess; for example, the built-in mouse devices usually seem to be connected via PS/2 whereas external mice are almost always USB.
Anyway, hopefully this will help:
#include <windows.h>
#include <Hidsdi.h>
#include <SetupAPI.h>
#include <devguid.h>
#include <stdio.h>
#pragma comment(lib, "hid.lib")
#pragma comment(lib, "setupapi.lib")
int main(int argc, char ** argv)
{
GUID hid_guid;
GUID mouse_guid = GUID_DEVCLASS_MOUSE;
HDEVINFO hdevinfo;
SP_DEVICE_INTERFACE_DATA devinterface;
SP_DEVINFO_DATA devinfo;
BYTE devdetailbuffer[4096];
PSP_DEVICE_INTERFACE_DETAIL_DATA devdetail;
DWORD n;
HidD_GetHidGuid(&hid_guid);
hdevinfo = SetupDiGetClassDevs(&hid_guid, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if (hdevinfo == INVALID_HANDLE_VALUE)
{
printf("SetupDiGetClassDevs: %u\n", GetLastError());
return 1;
}
for (n = 0;; n++)
{
devinterface.cbSize = sizeof(devinterface);
if (!SetupDiEnumDeviceInterfaces(hdevinfo, NULL, &hid_guid, n, &devinterface))
{
printf("SetupDiEnumDeviceInterfaces: %u\n", GetLastError());
break;
}
devdetail = (PSP_DEVICE_INTERFACE_DETAIL_DATA)devdetailbuffer;
devdetail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
devinfo.cbSize = sizeof(devinfo);
if (!SetupDiGetDeviceInterfaceDetail(hdevinfo, &devinterface, devdetail, sizeof(devdetailbuffer), NULL, &devinfo))
{
printf("SetupDiGetDeviceInterfaceDetail: %u\n", GetLastError());
break;
}
if (IsEqualGUID(&devinfo.ClassGuid, &mouse_guid))
{
// This is a mouse
printf("DevicePath: %ws\n", devdetail->DevicePath);
}
}
return 0;
}