MCPcopy Create free account
hub / github.com/mhammond/pywin32 / LocatePythonServiceClassString

Function LocatePythonServiceClassString

win32/src/PythonService.cpp:1282–1324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1280}
1281
1282BOOL LocatePythonServiceClassString( TCHAR *svcName, TCHAR *buf, int cchBuf)
1283{
1284 TCHAR keyName[1024];
1285
1286 // If not error loading, and not an empty string
1287 // (NOTE: Embedding a resource to specify the service name is
1288 // deprecated)
1289 if (LoadString(GetModuleHandle(NULL), RESOURCE_SERVICE_NAME, buf, cchBuf)>1)
1290 // Get out of here now!
1291 return TRUE;
1292
1293 HKEY key = NULL;
1294 BOOL ok = TRUE;
1295 _sntprintf(keyName, sizeof(keyName)/sizeof(keyName[0]),
1296 _T("System\\CurrentControlSet\\Services\\%s\\PythonClass"),
1297 svcName);
1298 if (RegOpenKey(HKEY_LOCAL_MACHINE, keyName, &key) != ERROR_SUCCESS) {
1299 ReportAPIError(PYS_E_API_CANT_LOCATE_PYTHON_CLASS);
1300 return FALSE;
1301 }
1302 DWORD dataType;
1303 DWORD valueBufSize = cchBuf * sizeof(TCHAR);
1304 if ((RegQueryValueEx(key, NULL, 0, &dataType, (LPBYTE)buf, &valueBufSize)!=ERROR_SUCCESS) ||
1305 (dataType != REG_SZ)) {
1306 ReportAPIError(PYS_E_API_CANT_LOCATE_PYTHON_CLASS);
1307 ok = FALSE;
1308 }
1309/***
1310 // See if the optimized flag is turned on.
1311 BOOL bOptimize;
1312 DWORD readSize = sizeof(bOptimize);
1313 if (key) {
1314 if ((RegQueryValueExA(key, "Optimize", 0, &dataType, (LPBYTE)&bOptimize, &readSize)!=ERROR_SUCCESS) ||
1315 (dataType != REG_DWORD)) {
1316 bOptimize = FALSE;
1317 }
1318 }
1319
1320***/
1321 if (key)
1322 RegCloseKey(key);
1323 return ok;
1324}
1325
1326// Register the EXE.
1327// This writes an entry to the Python registry and also

Callers 1

service_mainFunction · 0.85

Calls 2

LoadStringFunction · 0.85
ReportAPIErrorFunction · 0.85

Tested by

no test coverage detected