开发者

how do i make this so everything can use it? C++

开发者 https://www.devze.com 2022-12-20 17:09 出处:网络
im somewhat new to c++ so i don\'t know ho开发者_高级运维w to do this but my main point in recoding this is to incress the speed of my program, i have been coding a project

im somewhat new to c++ so i don't know ho开发者_高级运维w to do this but my main point in recoding this is to incress the speed of my program, i have been coding a project and my code is:

HWND hWnd = FindWindow(NULL, L"*window's name*");
DWORD th32ProcId;
HANDLE hProc;

GetWindowThreadProcessId(hWnd, &th32ProcId);

hProc = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, 0, th32ProcId);

so i have about 20 functions that all use that at the start of each time i run them and the value will never change so is there some way i can declare and then set it at the value of what it finds?

my code is set up like this

one main file int main() and it's just set on a loop and it keeps retesting and calls the other functions and everything else is in a void name() and i have 2 int name()

im using VC++ 2008.

edit no :| i just want a way i can share thoses values with all of the program.


If I understand your question correctly you want to implement some kind of caching. That would be fine and you can create a cahe with an std::map.

You would probably have something like:

std::map<std::string, HANDLE> cacheMap;

You can then check the cacheMap to see if a result exists. It if does exist you don't need to call the function, if it does not exist you would then call the function and add the result to your map.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号