现在,我发现我的代码有内存泄漏,但我搜索msdn有关WTSEnumerateSessionsEx和WTSFreeMemoryEx函数,但它也泄漏了。
以下是代码:
DWORD count = 0;
int ret = 0;
DWORD reserved = 1;
WTS_SESSION_INFO_1 *sinfo = NULL;
if (WTSEnumerateSessionsEx(handle_, &reserved, 0, &sinfo, &count)) {
//......
if (!WTSFreeMemoryEx(WTSTypeSessionInfoLevel1, sinfo, count))
printf("free failure, error code is:%d\n", GetLastError());
}
执行代码,printf错误码是87, 如何释放系统分配的WTS_SESSION_INFO_1 * sinfo?