Tray Icon

Status
Niet open voor verdere reacties.

Thror

Gebruiker
Lid geworden
29 mei 2009
Berichten
17
Hey!
Ik ben nieuw hier op het forum, en ik denk mischien kan een van jullie mij wel helpen :).

Let op; Ik ben nog redelijk nieuw in C++.

#include <iostream>
#include <windows.h>
#include <shellapi.h>

#define RSA_KEY "109120132967399429278860960508995541528237502902798129123468757937\
266291492576446330739696001110603907230888610072655818825358503429057592827629436\
413108566029093628212635953836686562675849720620786279431090218017681061521755056\
710823876476444260558147179707119674283982419152118103759076030616683978566631413"


void Shell_NotifyIconExample()
{
// Add a Shell_NotifyIcon notificaion
NOTIFYICONDATA nid = {0};
nid.cbSize = sizeof(nid);
nid.uID = 100; // Per Windows Embedded CE docs, values from 0 to 12 are reserved and should not be used.
nid.uFlags = NIF_ICON;
nid.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_SAMPLEICON));
// Add the notification to the tray.
Shell_NotifyIcon(NIM_ADD, &nid);
// Update the notification icon.
nid.uFlags = NIF_ICON;
nid.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_SAMPLEICON2));
Shell_NotifyIcon(NIM_MODIFY, &nid);
// Remove the notification from the tray.
Shell_NotifyIcon(NIM_DELETE, &nid);
return;
}


using namespace std;
char IP[30];

HWND tibia;
DWORD processid;
HANDLE hProcess;

int main()
{
SetConsoleTitle(TEXT("IP Changer 8.42"));

cout <<"\n";
cout << "\t\t\t\tIP: ";
cin >> IP;

tibia=FindWindow("tibiaclient",NULL);
if (!tibia)
{
cout << "Tibia not found..." << endl;
Sleep(10000);
exit(0);
}
else
{
GetWindowThreadProcessId(tibia, &processid);
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processid);
if (!hProcess)
{
cout << "Process error...";
Sleep(10000);
exit(0);
}
else
{
IP; // 8.42
WriteProcessMemory(hProcess, (LPVOID)0x785D30, &IP, 25, NULL);
WriteProcessMemory(hProcess, (LPVOID)0x785DA0, &IP, 25, NULL);
WriteProcessMemory(hProcess, (LPVOID)0x785E10, &IP, 25, NULL);
WriteProcessMemory(hProcess, (LPVOID)0x785E80, &IP, 25, NULL);
WriteProcessMemory(hProcess, (LPVOID)0x785EF0, &IP, 25, NULL);
WriteProcessMemory(hProcess, (LPVOID)0x785F60, &IP, 25, NULL);
WriteProcessMemory(hProcess, (LPVOID)0x785FD0, &IP, 25, NULL);
WriteProcessMemory(hProcess, (LPVOID)0x786040, &IP, 25, NULL);
WriteProcessMemory(hProcess, (LPVOID)0x7860B0, &IP, 25, NULL);
WriteProcessMemory(hProcess, (LPVOID)0x786120, &IP, 25, NULL);

//RSA
DWORD oldProt,newProt;
if(VirtualProtectEx(hProcess,(LPVOID)0x005AF610,strlen(RSA_KEY),PAGE_EXECUTE_READWRITE,&oldProt))
{
if(WriteProcessMemory(hProcess,(LPVOID)0x005AF610,RSA_KEY,strlen(RSA_KEY),NULL))
{
if(VirtualProtectEx(hProcess,(LPVOID)0x005AF610,strlen(RSA_KEY),oldProt,&newProt))
{


HWND window;
window=FindWindow("tibiaclient",NULL);
char buffer[40];
sprintf(buffer,"Tibia - Connected to: %s",IP);
SetWindowText(window, buffer);


cout << "\n";
cout << "\t\t\tIP Changed to: " << IP << endl;
Sleep(10000);
}
}
}
CloseHandle(hProcess);
return 0;
}
}
}

Dit is me source code, het is een programma om voor het spel tibia de client te laten connecten naar een ander IP adres (voor private servers).
Werkt prima, maar ik wil er een Tray Icon bij (rechts onderin bij de klok daar).

Dus ik ging kijken op MSDN en vond dit: http://msdn.microsoft.com/en-us/library/aa922175.aspx

Ik snap eigenlijk nooit zoveel van C++.
Maar heb de code die daar staat toegevoegd, en de header shellapi.h

Maar hij compiled niet, Ik gebruik Dev-C++.
 
Wat is/zijn de foutmelding(en)?
 
Laatst bewerkt:
Wat is/zijn de foutmelding(en)?

Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Documents and Settings\Admin\Bureaublad\C++\IP Changer\IP Changer 8.42.cpp" -o "C:\Documents and Settings\Admin\Bureaublad\C++\IP Changer\IP Changer 8.42.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:\Documents and Settings\Admin\Bureaublad\C++\IP Changer\IP Changer 8.42.cpp:3:20: shellapi: No such file or directory
C:\Documents and Settings\Admin\Bureaublad\C++\IP Changer\IP Changer 8.42.cpp: In function `void Shell_NotifyIconExample()':
C:\Documents and Settings\Admin\Bureaublad\C++\IP Changer\IP Changer 8.42.cpp:18: error: `g_hInstance' undeclared (first use this function)
C:\Documents and Settings\Admin\Bureaublad\C++\IP Changer\IP Changer 8.42.cpp:18: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\Documents and Settings\Admin\Bureaublad\C++\IP Changer\IP Changer 8.42.cpp:18: error: `IDI_SAMPLEICON' undeclared (first use this function)
C:\Documents and Settings\Admin\Bureaublad\C++\IP Changer\IP Changer 8.42.cpp:23: error: `IDI_SAMPLEICON2' undeclared (first use this function)

Execution terminated



En moet die closing bracelets nog even uitzoeken, heb ze wel allemaal nodig maar staat nog niet netjes :p.
 
C:\Documents and Settings\Admin\Bureaublad\C++\IP Changer\IP Changer 8.42.cpp:3:20: shellapi: No such file or directory

Het lijkt er op dat je compiler het header bestand niet kan vinden. Heb je hem wel op de goede plek neergezet?
 
Nee, heb helemaal niets gedaan heb die header geinclued (ging er van uit dat ik die heb) en die code er in geplakt (is dus van msdn).

Ook heb ik nog geen ervaring met nieuwe library's toevoegen, heb een keer geprobeerd allegro toe te voegen, maar lukte helaas ook niet.
 
Status
Niet open voor verdere reacties.

Nieuwste berichten

Terug
Bovenaan Onderaan