I'm winsock2, including winsock2.h, linking ws2_32.lib.
Code:
//(call WSAStartup(), etc.)
WSASERVICECLASSINFO sci;
WSANSCLASSINFO nsci[2];
DWORD port = 5632;
DWORD sapID = 5632;
DWORD dwValue = 1;
sci.dwCount = 2; //sizeof nsci
sci.lpClassInfos = nsci;
sci.lpServiceClassId = (LPGUID)&svcGUID;
sci.lpszServiceClassName = "RFTT Server";
nsci[0].dwNameSpace = NS_SAP;
nsci[0].lpszName = "ConnectionOriented";
nsci[0].dwValueType = REG_DWORD;
nsci[0].dwValueSize = sizeof(dwValue);
nsci[0].lpValue = &dwValue;
nsci[1].dwNameSpace = NS_SAP;
nsci[1].lpszName = SERVICE_TYPE_VALUE_SAPID;
nsci[1].dwValueType = REG_DWORD;
nsci[1].dwValueSize = sizeof(sapID);
nsci[1].lpValue = &sapID;
int res = WSAInstallServiceClass(&sci);
if(res == SOCKET_ERROR)
{
res = WSAGetLastError();
char temp[128];
itoa(res, temp, 10);
if(res == WSAEACCES)
MessageBox(NULL, "Insufficient privileges to install service class.",
"Error", MB_OK | MB_ICONEXCLAMATION);
else
MessageBox(NULL, temp, "Error", MB_OK | MB_ICONEXCLAMATION);
}
Actually, I just tested it on my home computer (WindowsXP Pro), and it apparently worked fine. The earlier error was at school. I checked res for WSAEACCES (since you can't modify the registry or anything on our accounts), WSAEINVAL, WSAEALREADY, and WSAENOTINITIALISED. The error testing in the code above is stripped-down, but should have the same effect. Always it skipped past the switch conditions, and the messagebox popped up with just '5'.