user-0 提问: 关于ListView_SetCheckStatic()函数的问题，为什么它不起作？

回复:
user: user-1
content: if (!AdjustPrivileges()) {         printf("Error:Couldn't AdjustPrivileges!\n");         exit(1);     }

user: user-0
content: 引用 1 楼 赵4老师的回复:bool AdjustPrivileges() {     HANDLE hToken;     TOKEN_PRIVILEGES tp;     TOKEN_PRIVILEGES oldtp;     DWORD dwSize=sizeof(TOKEN_PRIVILEGES);     LUID luid;      if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {         if (GetLastError()==ERROR_CALL_NOT_IMPLEMENTED) return true;         else return false;     }     if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luid)) {         CloseHandle(hToken);         return false;     }     ZeroMemory(&tp, sizeof(tp));     tp.PrivilegeCount=1;     tp.Privileges[0].Luid=luid;     tp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;     /* Adjust Token Privileges */     if (!AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), &oldtp, &dwSize)) {         CloseHandle(hToken);         return false;     }     // close handles     CloseHandle(hToken);     return true; }  请问这个函数怎么使用？

user: user-0
content: 引用 2 楼 赵4老师的回复:void MyGetListViewItem(HWND hWindow,TStrings *strlist) {     const nMaxLen=1023;     char szBuf[nMaxLen+1];     char buf[nMaxLen+1];      int          nLVItemCount;     int          nColumns;     DWORD        dwProcessID;     HANDLE       hProcess;     HANDLE       hHeaderCtrl;     LVITEM       lvItemLocal;     HDITEM       hdItemLocal;     DWORD        dwBytesRead, dwBytesWrite;     bool         bSuccess,bWriteOK;      //注意：本文来自www.ccrun.com，by ccrun(老妖)，转载请注明出处。     //本文转自 C++Builder研究 - http://www.ccrun.com/article.asp?i=583&d=eahk4z     //为防止某些不负责任的转载者，故出此下策，在代码中加入声明，请大家原谅。      GetWindowThreadProcessId(hWindow,&dwProcessID);     hProcess=OpenProcess(PROCESS_ALL_ACCESS,FALSE,dwProcessID);     if(!hProcess)  //得不到指定进程的句柄         return;     //在指定进程内分配存储空间     LPVOID lpTextRemote=VirtualAllocEx(hProcess,NULL,nMaxLen+1,MEM_COMMIT,PAGE_READWRITE);     LPVOID lpListItemRemote=VirtualAllocEx(hProcess,NULL,sizeof(LVITEM),MEM_COMMIT,PAGE_READWRITE);     LPVOID lpHeadItemRemote=VirtualAllocEx(hProcess,NULL,sizeof(HDITEM),MEM_COMMIT,PAGE_READWRITE);     if((!lpTextRemote) || (!lpListItemRemote) || (!lpHeadItemRemote)) //不能在指定进程内分配存储空间         return;      nLVItemCount=ListView_GetItemCount(hWindow);     hHeaderCtrl=ListView_GetHeader(hWindow);     nColumns=Header_GetItemCount(hHeaderCtrl);     if (nColumns<=0) {         nColumns=1;     } else {         buf[0]=0;         for (int j=0;j<nColumns;j++) {             ZeroMemory(szBuf,nMaxLen+1);             bWriteOK= WriteProcessMemory(hProcess,lpTextRemote,(LPVOID)szBuf,nMaxLen+1,(LPDWORD)&dwBytesWrite);             if(!bWriteOK) //写内存错误                 return;             hdItemLocal.mask=HDI_TEXT;             hdItemLocal.cchTextMax=nMaxLen;             hdItemLocal.pszText=(LPTSTR)lpTextRemote;             dwBytesWrite=0;             bWriteOK=WriteProcessMemory(hProcess,lpHeadItemRemote,(LPVOID)&hdItemLocal,sizeof(HDITEM),(LPDWORD)&dwBytesWrite);             if(!bWriteOK) //写内存错误                 return;              SendMessage(hHeaderCtrl,HDM_GETITEM,(WPARAM)j,(LPARAM)lpHeadItemRemote);             bSuccess=ReadProcessMemory(hProcess,lpTextRemote,szBuf,nMaxLen+1,&dwBytesRead);             //从指定进程存储空间读取文本             if(!bSuccess) //不能在指定进程内读取文本                 return;             if (j>0) strcat(buf,"|");             strcat(buf,AnsiString(szBuf).c_str());         }         strlist->Add(buf);     } //  strlist->Add("ListView的Columns数: " + String(nColumns)); //  strlist->Add("---------------------------");      for (int i=0;i<nLVItemCount;i++) {         buf[0]=0;         for (int j=0;j<nColumns;j++) {             ZeroMemory(szBuf,nMaxLen+1);             bWriteOK= WriteProcessMemory(hProcess,lpTextRemote,(LPVOID)szBuf,nMaxLen+1,(LPDWORD)&dwBytesWrite);             if(!bWriteOK) //写内存错误                 return;             lvItemLocal.iItem=i;             lvItemLocal.iSubItem=j;             lvItemLocal.mask=LVIF_TEXT;             lvItemLocal.cchTextMax=nMaxLen;             lvItemLocal.pszText=(LPTSTR)lpTextRemote;             dwBytesWrite=0;             bWriteOK=WriteProcessMemory(hProcess,lpListItemRemote,(LPVOID)&lvItemLocal,sizeof(LVITEM),(LPDWORD)&dwBytesWrite);             if(!bWriteOK) //写内存错误                 return;             SendMessage(hWindow,LVM_GETITEMTEXT,(WPARAM)i,(LPARAM)lpListItemRemote);             bSuccess=ReadProcessMemory(hProcess,lpTextRemote,szBuf,nMaxLen+1,&dwBytesRead);             //从指定进程存储空间读取文本             if(!bSuccess) //不能在指定进程内读取文本                 return;             if (j>0) strcat(buf,"|");             strcat(buf,AnsiString(szBuf).c_str());         }         strlist->Add(buf);     }//end of for(i)     //在指定进程内释放存储空间     VirtualFreeEx(hProcess,lpHeadItemRemote,0,MEM_RELEASE);     VirtualFreeEx(hProcess,lpListItemRemote,0,MEM_RELEASE);     VirtualFreeEx(hProcess,lpTextRemote,0,MEM_RELEASE);     //关闭指定进程句柄     CloseHandle(hProcess); } //---------------------------------------------------------------------------  我怎么找不到那个 TStrings类型的变量呢？

user: user-1
content: void MyGetListViewItem(HWND hWindow,TStrings *strlist) {     const nMaxLen=1023;     char szBuf[nMaxLen+1];     char buf[nMaxLen+1];      int          nLVItemCount;     int          nColumns;     DWORD        dwProcessID;     HANDLE       hProcess;     HANDLE       hHeaderCtrl;     LVITEM       lvItemLocal;     HDITEM       hdItemLocal;     DWORD        dwBytesRead, dwBytesWrite;     bool         bSuccess,bWriteOK;      //注意：本文来自www.ccrun.com，by ccrun(老妖)，转载请注明出处。     //本文转自 C++Builder研究 - http://www.ccrun.com/article.asp?i=583&d=eahk4z     //为防止某些不负责任的转载者，故出此下策，在代码中加入声明，请大家原谅。      GetWindowThreadProcessId(hWindow,&dwProcessID);     hProcess=OpenProcess(PROCESS_ALL_ACCESS,FALSE,dwProcessID);     if(!hProcess)  //得不到指定进程的句柄         return;     //在指定进程内分配存储空间     LPVOID lpTextRemote=VirtualAllocEx(hProcess,NULL,nMaxLen+1,MEM_COMMIT,PAGE_READWRITE);     LPVOID lpListItemRemote=VirtualAllocEx(hProcess,NULL,sizeof(LVITEM),MEM_COMMIT,PAGE_READWRITE);     LPVOID lpHeadItemRemote=VirtualAllocEx(hProcess,NULL,sizeof(HDITEM),MEM_COMMIT,PAGE_READWRITE);     if((!lpTextRemote) || (!lpListItemRemote) || (!lpHeadItemRemote)) //不能在指定进程内分配存储空间         return;      nLVItemCount=ListView_GetItemCount(hWindow);     hHeaderCtrl=ListView_GetHeader(hWindow);     nColumns=Header_GetItemCount(hHeaderCtrl);     if (nColumns<=0) {         nColumns=1;     } else {         buf[0]=0;         for (int j=0;j<nColumns;j++) {             ZeroMemory(szBuf,nMaxLen+1);             bWriteOK= WriteProcessMemory(hProcess,lpTextRemote,(LPVOID)szBuf,nMaxLen+1,(LPDWORD)&dwBytesWrite);             if(!bWriteOK) //写内存错误                 return;             hdItemLocal.mask=HDI_TEXT;             hdItemLocal.cchTextMax=nMaxLen;             hdItemLocal.pszText=(LPTSTR)lpTextRemote;             dwBytesWrite=0;             bWriteOK=WriteProcessMemory(hProcess,lpHeadItemRemote,(LPVOID)&hdItemLocal,sizeof(HDITEM),(LPDWORD)&dwBytesWrite);             if(!bWriteOK) //写内存错误                 return;              SendMessage(hHeaderCtrl,HDM_GETITEM,(WPARAM)j,(LPARAM)lpHeadItemRemote);             bSuccess=ReadProcessMemory(hProcess,lpTextRemote,szBuf,nMaxLen+1,&dwBytesRead);             //从指定进程存储空间读取文本             if(!bSuccess) //不能在指定进程内读取文本                 return;             if (j>0) strcat(buf,"|");             strcat(buf,AnsiString(szBuf).c_str());         }         strlist->Add(buf);     } //  strlist->Add("ListView的Columns数: " + String(nColumns)); //  strlist->Add("---------------------------");      for (int i=0;i<nLVItemCount;i++) {         buf[0]=0;         for (int j=0;j<nColumns;j++) {             ZeroMemory(szBuf,nMaxLen+1);             bWriteOK= WriteProcessMemory(hProcess,lpTextRemote,(LPVOID)szBuf,nMaxLen+1,(LPDWORD)&dwBytesWrite);             if(!bWriteOK) //写内存错误                 return;             lvItemLocal.iItem=i;             lvItemLocal.iSubItem=j;             lvItemLocal.mask=LVIF_TEXT;             lvItemLocal.cchTextMax=nMaxLen;             lvItemLocal.pszText=(LPTSTR)lpTextRemote;             dwBytesWrite=0;             bWriteOK=WriteProcessMemory(hProcess,lpListItemRemote,(LPVOID)&lvItemLocal,sizeof(LVITEM),(LPDWORD)&dwBytesWrite);             if(!bWriteOK) //写内存错误                 return;             SendMessage(hWindow,LVM_GETITEMTEXT,(WPARAM)i,(LPARAM)lpListItemRemote);             bSuccess=ReadProcessMemory(hProcess,lpTextRemote,szBuf,nMaxLen+1,&dwBytesRead);             //从指定进程存储空间读取文本             if(!bSuccess) //不能在指定进程内读取文本                 return;             if (j>0) strcat(buf,"|");             strcat(buf,AnsiString(szBuf).c_str());         }         strlist->Add(buf);     }//end of for(i)     //在指定进程内释放存储空间     VirtualFreeEx(hProcess,lpHeadItemRemote,0,MEM_RELEASE);     VirtualFreeEx(hProcess,lpListItemRemote,0,MEM_RELEASE);     VirtualFreeEx(hProcess,lpTextRemote,0,MEM_RELEASE);     //关闭指定进程句柄     CloseHandle(hProcess); } //---------------------------------------------------------------------------

user: user-1
content: bool AdjustPrivileges() {     HANDLE hToken;     TOKEN_PRIVILEGES tp;     TOKEN_PRIVILEGES oldtp;     DWORD dwSize=sizeof(TOKEN_PRIVILEGES);     LUID luid;      if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {         if (GetLastError()==ERROR_CALL_NOT_IMPLEMENTED) return true;         else return false;     }     if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luid)) {         CloseHandle(hToken);         return false;     }     ZeroMemory(&tp, sizeof(tp));     tp.PrivilegeCount=1;     tp.Privileges[0].Luid=luid;     tp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;     /* Adjust Token Privileges */     if (!AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), &oldtp, &dwSize)) {         CloseHandle(hToken);         return false;     }     // close handles     CloseHandle(hToken);     return true; }