我在这个网站上搜索了一个答案,最佳答案对我不起作用,我一直收到这个错误。我最近(不确定我是否成功)从我的桌面到我的新笔记本电脑导入了我的项目,没有任何错误。每当我尝试运行时,我会在多个文件中出现此错误,仅使用一个作为示例:
错误C2664:' DWORD CHackProcess :: GetModuleNamePointer(LPSTR,DWORD)':无法从' const char [11]'转换参数1到了' LPSTR'
这是以下几行:
while (__dwordClient == 0x0) __dwordClient = GetModuleNamePointer("client.dll", __gameProcess.th32ProcessID);
while (__dwordEngine == 0x0) __dwordEngine = GetModuleNamePointer("engine.dll"6, __gameProcess.th32ProcessID);
while (__dwordVGui == 0x0) __dwordVGui = GetModuleNamePointer("vguimatsurface.dll", __gameProcess.th32ProcessID);
答案 0 :(得分:1)
MSDN说明typedef char* PSTR, *LPSTR;
的以下定义:
const
这意味着它是非char engineModuleName[] = "engine.dll";
GetModuleNamePointer(engineModuleName, __gameProcess.th32ProcessID);
表达式。你传递的字符串是不变的。
您只需将非常量字符串作为第一个参数传递。
编辑:
可以翻译成以下内容:
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
checkServiceRunning(MyService.class);
}
public boolean checkServiceRunning(Class<MyService> myServiceClass){
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE))
{
if ("com.example.processlistener"
.equals(service.service.getClassName()))
{
Toast.makeText(this, "Hi!", Toast.LENGTH_SHORT).show();
return true;
}
}
return false;
}
}