sleeppower Napisano Lipiec 2, 2019 Autor Zgłoś Napisano Lipiec 2, 2019 HKEY hKey; RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\jajo",0,KEY_ALL_ACCESS,&hKey); TCHAR achKey[MAX_KEY_LENGTH]; // buffer for subkey name DWORD cbName; // size of name string TCHAR achClass[MAX_PATH] = TEXT(""); // buffer for class name DWORD cchClassName = MAX_PATH; // size of class string DWORD cSubKeys=0; // number of subkeys DWORD cbMaxSubKey; // longest subkey size DWORD cchMaxClass; // longest class string DWORD cValues; // number of values for key DWORD cchMaxValue; // longest value name DWORD cbMaxValueData; // longest value data DWORD cbSecurityDescriptor; // size of security descriptor FILETIME ftLastWriteTime; // last write time DWORD i, retCode; TCHAR achValue[MAX_VALUE_NAME]; DWORD cchValue = MAX_VALUE_NAME; // Get the class name and the value count. retCode = RegQueryInfoKey( hKey, // key handle achClass, // buffer for class name &cchClassName, // size of class string NULL, // reserved &cSubKeys, // number of subkeys &cbMaxSubKey, // longest subkey size &cchMaxClass, // longest class string &cValues, // number of values for this key &cchMaxValue, // longest value name &cbMaxValueData, // longest value data &cbSecurityDescriptor, // security descriptor &ftLastWriteTime); // last write time RegCloseKey(hKey); int liczba = (int) cValues; LPCTSTR ile; LPCTSTR tresc; for (int i=0;i<liczba;i++) { cchValue = MAX_VALUE_NAME; achValue[0] = '\0'; retCode = RegEnumValue(hKey, i, achValue, &cchValue, NULL, NULL, NULL, NULL); MessageBox(hwnd,achValue,"info",MB_OK); } ile = liczba + "adas"; MessageBox(hwnd,ile,"Ile",MB_OK); Czy moze mi ktos powiedziec dlaczego kod ten nie wyswietla mi informacji o tym ile jest wartosci w podanym kluczu i w ogule jakie one maja nazwe ?? Nie wiem co zle zrobilem. Kod ten wyciagnelem od Microsoftu z biblioteki msdn. No chyba ze uzylem zlych funkcji. Prosze pomozcie Cytuj
Surprise Napisano Lipiec 2, 2019 Zgłoś Napisano Lipiec 2, 2019 Witaj sleeppower!!! Coś mi się zdaje, że w tym tkwi błąd: ile = liczba + "adas"; LPCTSTR to samo co char *. A więc moim zdaniem powinieneś to tak napisać: wsprinf(ile, "%d adas", liczba) ; Funkcja wsprinft to odpowiednik sprinft w winapi. Powodzenia Cytuj
sleeppower Napisano Lipiec 2, 2019 Autor Zgłoś Napisano Lipiec 2, 2019 chyba nie to wywala mi błą: implicit declaration of function `int sprinft(...)' :( Cytuj
Surprise Napisano Lipiec 2, 2019 Zgłoś Napisano Lipiec 2, 2019 Sorki, ostatnio sam nie wiem co pisze :D małe sprostowanie: Funkcja wsprinft to w winapi odpowiednik sprinft w c. Chodziło mi o to że w winapi możesz użyć funkcji wsprintf zamiast dodawać biblioteki c, w których jest ta sama funkcja o nazwie sprintf. Pozdro Cytuj
Storm Napisano Lipiec 3, 2019 Zgłoś Napisano Lipiec 3, 2019 Witam troszke przerobilem twoj kod powinno byc ok //--------------------------------------------------------------------------- #include <windows.h> #include <stdio.h> #include <stdarg.h> #define MAX_KEY_LENGTH 255 #define MAX_VALUE_NAME 16000 #define MAX_PATH 16000 //--------------------------------------------------------------------------- int MessageBoxPrintf(CHAR * szCaption,CHAR * szFormat, ...) { va_list wsk_na_liste_arg; CHAR bufor[1024]; va_start(wsk_na_liste_arg,szFormat); _vsnprintf(bufor,sizeof(bufor),szFormat,wsk_na_liste_arg); va_end(wsk_na_liste_arg); return MessageBox(NULL,bufor,szCaption,0); } //--------------------------------------------------------------------------- WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // HKEY hKey; if( RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\jajo",0,KEY_ALL_ACCESS,&hKey) == ERROR_SUCCESS ) { TCHAR achKey[MAX_KEY_LENGTH]; // buffer for subkey name DWORD cbName; // size of name string TCHAR achClass[MAX_PATH] = TEXT(""); // buffer for class name DWORD cchClassName = MAX_PATH; // size of class string DWORD cSubKeys=0; // number of subkeys DWORD cbMaxSubKey; // longest subkey size DWORD cchMaxClass; // longest class string DWORD cValues; // number of values for key DWORD cchMaxValue; // longest value name DWORD cbMaxValueData; // longest value data DWORD cbSecurityDescriptor; // size of security descriptor FILETIME ftLastWriteTime; // last write time DWORD i, retCode; TCHAR achValue[MAX_VALUE_NAME]; DWORD cchValue = MAX_VALUE_NAME; // Get the class name and the value count. if( (retCode = RegQueryInfoKey( hKey, // key handle achClass, // buffer for class name &cchClassName, // size of class string NULL, // reserved &cSubKeys, // number of subkeys &cbMaxSubKey, // longest subkey size &cchMaxClass, // longest class string &cValues, // number of values for this key &cchMaxValue, // longest value name &cbMaxValueData, // longest value data &cbSecurityDescriptor, // security descriptor &ftLastWriteTime) // last write time )==ERROR_SUCCESS) { //RegCloseKey(hKey); int liczba = (int) cValues; LPCTSTR ile; LPCTSTR tresc; for (int i=0;i<liczba;i++) { cchValue = MAX_VALUE_NAME; achValue[0] = '\0'; retCode = RegEnumValue(hKey, i, achValue, &cchValue, NULL, NULL, NULL, NULL); MessageBox(NULL,achValue,"info",MB_OK); } //ile = liczba + "adas"; //MessageBox(NULL,ile,"Ile",MB_OK); MessageBoxPrintf("Ile","Znaleziono %d wartosci",liczba); } RegCloseKey(hKey); } return 0; } //--------------------------------------------------------------------------- Pozdrawiam Cytuj
sleeppower Napisano Lipiec 3, 2019 Autor Zgłoś Napisano Lipiec 3, 2019 Nie działa niestety. Niby nie ma zadnych bledow ale jak uruchamiam program to sie sam wylacza a moze to wina kompilatora bo pisze w Dev C++ :( :( Cytuj
sleeppower Napisano Lipiec 3, 2019 Autor Zgłoś Napisano Lipiec 3, 2019 Hehe juz dziala mialem cos naryte w kodzie dzieki Pytanko mam jeszcze jedno co znacza te trzy kropki w funkcji MessageBoxPrintf Cytuj
Storm Napisano Lipiec 3, 2019 Zgłoś Napisano Lipiec 3, 2019 Jest to funkcja o dowolnej liczbie argumentów jak printf w C. Pozdro Cytuj
Storm Napisano Lipiec 3, 2019 Zgłoś Napisano Lipiec 3, 2019 Jest to funkcja o dowolnej liczbie argumentów jak printf w C. Pozdro Cytuj
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.