This example works in Win7 as normal user:
#define WIN32_DEFAULT_LIBS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
int __cdecl WinMainCRTStartup(void)
{
HANDLE hCom;
TCHAR szCom[] = TEXT("\\\\.\\COM2");
if ((hCom = CreateFile(szCom, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE) {
CloseHandle(hCom);
MessageBox(0, TEXT("Open"), szCom, MB_OK);
} else {
MessageBox(0, TEXT("Error"), szCom, MB_OK);
}
ExitProcess(0);
}