| | |
FindWindow Problems (on Windows 98/ME)
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2006
Posts: 4
Reputation:
Solved Threads: 0
Hello folks 
Allow me to introduce myself. I am Haktivex, a programmer for a tool known as TibiCAM, used to record movies for an online game known as Tibia.
Now heres the issue. For a long time we supported all operating systems, Windows 98, ME, etc. However recently these operating systems have stopped working. Some things to note:
1. We switched compilers (Microsoft Visual C++ Express) - Originally was compiled on Visual C++ 6.0
2. Compiling on Visual C++ 2003 did not help either.
3. None of the FindWindow code was changed.
4. Works fine on XP, etc.
When running on Windows 98/ME, instead of FindWindow finding the Tibia client, instead it finds DLL files, usually something like directx files, and some people have reported it finding Gadu-Gadu (IM program) files.
I have considered that the issue could be caused by ansi/unicode but I have no grounds to confirm this consideration. It could also be the compilers. Would anybody suggest that the Visual C++ 6.0 be used? Or is there something we can change with our current compilers/IDE's to get support back?
Here is the single line of code that is giving us so much trouble:
Thanks alot,
Haktivex.

Allow me to introduce myself. I am Haktivex, a programmer for a tool known as TibiCAM, used to record movies for an online game known as Tibia.
Now heres the issue. For a long time we supported all operating systems, Windows 98, ME, etc. However recently these operating systems have stopped working. Some things to note:
1. We switched compilers (Microsoft Visual C++ Express) - Originally was compiled on Visual C++ 6.0
2. Compiling on Visual C++ 2003 did not help either.
3. None of the FindWindow code was changed.
4. Works fine on XP, etc.
When running on Windows 98/ME, instead of FindWindow finding the Tibia client, instead it finds DLL files, usually something like directx files, and some people have reported it finding Gadu-Gadu (IM program) files.
I have considered that the issue could be caused by ansi/unicode but I have no grounds to confirm this consideration. It could also be the compilers. Would anybody suggest that the Visual C++ 6.0 be used? Or is there something we can change with our current compilers/IDE's to get support back?
Here is the single line of code that is giving us so much trouble:
C++ Syntax (Toggle Plain Text)
HWND hTemp = FindWindow("tibiaclient", NULL);
Thanks alot,
Haktivex.
•
•
Join Date: Sep 2006
Posts: 4
Reputation:
Solved Threads: 0
•
•
•
•
I don't know why these errors occur, but you might want to try creating processsnapshots to find the handles.
This way is a bit harder, and it's much more code, but it might just work, right?
Greetz, Eddy
Process Snapshots require (as far as I am concerned) the process id of an application, which can be found using FindWindow - which is causing us these troubles.
Regards,
Haktivex.
•
•
Join Date: Jul 2006
Posts: 56
Reputation:
Solved Threads: 3
C++ Syntax (Toggle Plain Text)
// snapshot.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <windows.h> #include <iostream> #include <stdio.h> #include <Tlhelp32.h> using namespace std; int main(int argc, char* argv[]) { DWORD tibiaID; HANDLE hProcessSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0); if(hProcessSnapshot == INVALID_HANDLE_VALUE) { cout << "invalid snapshot handle" << endl; } PROCESSENTRY32 ProcessStruct; ProcessStruct.dwSize = sizeof(PROCESSENTRY32); Process32First(hProcessSnapshot, &ProcessStruct); if(strcmp(ProcessStruct.szExeFile, "tibia.exe") == 0) { //you have the right process. tibiaID = ProcessStruct.th32ProcessID; } else { // tibia.exe is not the first process //looping through the other records while(Process32Next(hProcessSnapshot, &ProcessStruct)) { if(strcmp(ProcessStruct.szExeFile, "tibia.exe") == 0) { //the right record has been found tibiaID = ProcessStruct.th32ProcessID; break; } } } cout << tibiaID; return 0; }
retreives the processID of tibia.exe. You can also compare to the module name of tibia.exe.
Creating a handle from the ID is something you already know, so that won't be a problem.
Yours,
Eddy
> HWND hTemp = FindWindow("tibiaclient", NULL);
The newer compilers use UNICODE by default.
I think you can either turn this off.
Or prepare your code for the future by writing
HWND hTemp = FindWindow( _TEXT("tibiaclient"), NULL);
http://www.i18nguy.com/unicode/c-unicode.html
The newer compilers use UNICODE by default.
I think you can either turn this off.
Or prepare your code for the future by writing
HWND hTemp = FindWindow( _TEXT("tibiaclient"), NULL);
http://www.i18nguy.com/unicode/c-unicode.html
•
•
Join Date: Sep 2006
Posts: 4
Reputation:
Solved Threads: 0
Thanks for your reply Salem.
Unfortunately, I have just realized that I was looking after the wrong problem all along. FindWindow is doing it's job correctly, it is the next few lines causing the problem.
Under Windows NT/XP/ etc this works just fine and dandy, and returns the path correctly. However, under Windows 98/ME etc, this returns some file not relevant to what we are searching for. The FindWindow procedure as originally thought to be the problem is not.
Unfortunately, I have just realized that I was looking after the wrong problem all along. FindWindow is doing it's job correctly, it is the next few lines causing the problem.
C++ Syntax (Toggle Plain Text)
// Now get the ProcessID, so we can get a snapshot and open the process. GetWindowThreadProcessId(hTemp, &lTibiaProcessID); hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, lTibiaProcessID); Module32First(hSnapshot, modA); strcpy(szTibiaPath, modA->szExePath);
Last edited by Haktivex; Oct 31st, 2006 at 2:52 am.
![]() |
Similar Threads
- Motherboard problems with Windows 2000 Installation? (Motherboards, CPUs and RAM)
- I Have Major Problems W/ Windows Me (Windows 95 / 98 / Me)
- Problems Downloading Windows XP (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: using borland lib classes
- Next Thread: Please help me figure out whats wrong with my code
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






