Windows 如何通过调用WTSEnumerateSessionEx释放内存malloced?

Windows 如何通过调用WTSEnumerateSessionEx释放内存malloced?,windows,Windows,现在,我发现我的代码有内存泄漏,但我搜索了msdn关于WTSEnumerateSessionEx和WTSFreeMemoryEx函数,但它也泄漏了 代码如下: DWORD count = 0; int ret = 0; DWORD reserved = 1; WTS_SESSION_INFO_1 *sinfo = NULL; if (WTSEnumerateSessionsEx(handle_, &reserved, 0, &sinfo, &count)) { /

现在,我发现我的代码有内存泄漏,但我搜索了msdn关于WTSEnumerateSessionEx和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 errorcode为87,
如何释放系统分配的WTS_SESSION_INFO_1*sinfo?

87是-您是否在
/…内部操作
sinfo
count
?我不更改sinfo和count值。谢谢您的回答,我找到了答案,我的开发环境是vs2008,我设置的字符集是多字节集,所以WTS_SESSION_INFO_1是WTS_SESSION_INFO_1A类型,当我更改为unicode集时,WTSFreeMemoryEx的调用成功。