我说预期的构造函数,析构函数或类型转换befor(令牌 [英] I says expected constructor, destructor, or type conversion befor ( token

查看:102
本文介绍了我说预期的构造函数,析构函数或类型转换befor(令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <iostream>
#include <windows.h>
#include "psapi.h"

using namespace std;
DWORD GetModuleBase(HANDLE hProc, string &sModuleName)
{
   HMODULE *hModules;
   char szBuf[50];
   DWORD cModules;
   DWORD dwBase = -1;
   //------

   EnumProcessModules(hProc, hModules, 0, &cModules);
   hModules = new HMODULE[cModules/sizeof(HMODULE)];

   if(EnumProcessModules(hProc, hModules, cModules/sizeof(HMODULE), &cModules)) {
      for(int i = 0; i < cModules/sizeof(HMODULE); i++) {
         if(GetModuleBaseName(hProc, hModules[i], szBuf, sizeof(szBuf))) {
            if(sModuleName.compare(szBuf) == 0) {
               dwBase = (DWORD)hModules[i];
               break;
            }
         }
      }
   }

   delete[] hModules;

   return dwBase;
}

GetModuleBase(hProc, string("winmine.exe"));





我尝试过:





What I have tried:

#include <iostream>
#include <windows.h>
#include "psapi.h"

using namespace std;
DWORD GetModuleBase(HANDLE hProc, string &sModuleName)
{
   HMODULE *hModules;
   char szBuf[50];
   DWORD cModules;
   DWORD dwBase = -1;
   //------

   EnumProcessModules(hProc, hModules, 0, &cModules);
   hModules = new HMODULE[cModules/sizeof(HMODULE)];

   if(EnumProcessModules(hProc, hModules, cModules/sizeof(HMODULE), &cModules)) {
      for(int i = 0; i < cModules/sizeof(HMODULE); i++) {
         if(GetModuleBaseName(hProc, hModules[i], szBuf, sizeof(szBuf))) {
            if(sModuleName.compare(szBuf) == 0) {
               dwBase = (DWORD)hModules[i];
               break;
            }
         }
      }
   }

   delete[] hModules;

   return dwBase;
}

GetModuleBase(hProc, string("winmine.exe"));

推荐答案

GetModuleBase 的调用超出任何函数定义,因此无法执行。试试这个:

The call to GetModuleBase is outside any function definition, and so can't be executed. Try this:
int main()
{
    GetModuleBase(hProc, string("winmine.exe"));
}

或者在现有函数定义中包含调用。

Or include the call in an existing function definition.


这篇关于我说预期的构造函数,析构函数或类型转换befor(令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆