我发现该功能ConvertStringSecurityDescriptorToSecurityDescriptor()
正在阻止我的程序正确结束。即使我打电话ExitProcess(0)
,我的程序也会在后台保持打开状态。如果我删除此功能,程序会正常结束。
在调试器的帮助下,我发现此函数创建了一个新线程,该线程在此函数结束后保持打开状态。
如何强制此函数正常运行并关闭它打开的所有线程?
我的代码:
int main() {
PSECURITY_DESCRIPTOR d;
// program has 1 thread
ConvertStringSecurityDescriptorToSecurityDescriptorW(L".....", SDDL_REVISION_1, &d, NULL);
// program has 2 threads
return 0; // still running in background after this
}