REGISTRY PROBLEM!!!
-
Hi Leutz!
Ich hab folgender Code, der eignetlich prüfen soll, ob der Schlüssel vorhanden ist....
Es gibt aber beim Compilen ein Fehler!
Der Code:BOOL RegKeyExists(HKEY hKey, LPCTSTR lpSubKey) { BOOL bRet; HKEY hSubKey; if(!RegOpenKeyEx(hKey, lpSubKey, 0, 0, &hSubKey)) { bRet = (GetLastError() == ERROR_FILE_NOT_FOUND) ? FALSE : TRUE; } else { RegCloseKey(hSubKey); bRet = TRUE; } return(bRet); } if(RegKeyExists(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows"))) { goto ok; } else { CFreischaltDlg dlgSerial; dlgSerial.DoModal(); } ok:
Der Fehler:
*D:\Abrechnung\Abrechnung\hilfeDlg.cpp(143) : error C2601: 'RegKeyExists' : local function definitions are illegal
*
-
lol
schau dir den code nochmal an.
-
Ach....
deswegen etwa??? FALSE : TRUE;
-
Original erstellt von Programmer85:
**Ach....
deswegen etwa??? FALSE : TRUE;**
ne, doch net...
Hmm.. in der FAQ steht, dass "Microsoft\\Software\...." unzulässig ist...
hmm..... jo! ich komm net drauf...
-
Schau dir mal deine Klammernsetzung an. Auch vor deiner FUnktion. Und les die Fehlermeldung!! Hat die was mit "? FALSE : TRUE; " zu tun ???
-
Original erstellt von dEUs:
Schau dir mal deine Klammernsetzung an. Auch vor deiner FUnktion. Und les die Fehlermeldung!! Hat die was mit "? FALSE : TRUE; " zu tun ???Die Klammern finde ich in Ordnung, da sehe ich keine Fehler...
? FALSE : TRUE; hab ich gelöscht, bekomm aber immer noch der gleiche Fehler...
-
Mein Gott. Die Klammern SIND DEFINITIV falsch!
Entweder steht deine FUnktion direkt innerhalb einer anderen oder duz hast bei ner anderen am Ende nur ne geschweifte Klammer vergessen!!
-
Okay... Hier hab ich mal die ganze FUnktion OnPaint();
void CHilfeDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); //Draw the Time } else { UpdateData(TRUE); //Überprüfen ob DATEI existiert (Grund: FREISCHALTEN!!) BOOL RegKeyExists(HKEY hKey, LPCTSTR lpSubKey) { BOOL bRet; HKEY hSubKey; if(!RegOpenKeyEx(hKey, lpSubKey, 0, 0, &hSubKey)) { bRet = (GetLastError() == ERROR_FILE_NOT_FOUND) ? FALSE : TRUE; } else { RegCloseKey(hSubKey); bRet = TRUE; } return(bRet); } if(RegKeyExists(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows"))) { goto ok; } else { CFreischaltDlg dlgSerial; dlgSerial.DoModal(); } ok: //Wenn nicht, dann CODE verlangen oder DEMO Version!) CPaintDC dc(this); CTime AktuelleZeit; AktuelleZeit = CTime::GetCurrentTime(); dc.TextOut(90, 315, AktuelleZeit.Format("%A, %d %B, %Y")); SetTimer(1,1000,NULL); CDialog::OnPaint(); } }
-
-Kein Kommentar mehr!!-
Ich und die Fehlermeldung haben dir schon alles geliefert, was du benötigst! DENK MAL SELBST!!! Ich hasse es, wenn Leute ihr gehrin nicht einschalten, so nach dem Motto: "Das Forum wirds schon richten"
-
Original erstellt von Programmer85:
**Okay... Hier hab ich mal die ganze FUnktion OnPaint();void CHilfeDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); //Draw the Time } else { UpdateData(TRUE); //Überprüfen ob DATEI existiert (Grund: FREISCHALTEN!!) BOOL RegKeyExists(HKEY hKey, LPCTSTR lpSubKey) { BOOL bRet; HKEY hSubKey; if(!RegOpenKeyEx(hKey, lpSubKey, 0, 0, &hSubKey)) { bRet = (GetLastError() == ERROR_FILE_NOT_FOUND) ? FALSE : TRUE; } else { RegCloseKey(hSubKey); bRet = TRUE; } return(bRet); } if(RegKeyExists(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows"))) { goto ok; } else { CFreischaltDlg dlgSerial; dlgSerial.DoModal(); } ok: //Wenn nicht, dann CODE verlangen oder DEMO Version!) CPaintDC dc(this); CTime AktuelleZeit; AktuelleZeit = CTime::GetCurrentTime(); dc.TextOut(90, 315, AktuelleZeit.Format("%A, %d %B, %Y")); SetTimer(1,1000,NULL); CDialog::OnPaint(); } }
**
Die Kommentare musste net beachten....
Sind alt, habs sie nur net gelöscht!
-
Kleiner Tipp: http://www.volkard.de/vcppkold/inhalt.html