0

现在,我发现我的代码有内存泄漏,但我在 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?

4

0 回答 0