Click here to Skip to main content
15,918,330 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Interact with Windows Services Pin
ThatsAlok14-Sep-05 21:50
ThatsAlok14-Sep-05 21:50 
AnswerRe: Interact with Windows Services Pin
ThatsAlok14-Sep-05 0:46
ThatsAlok14-Sep-05 0:46 
Questionwhy does only a part of VARIANT change from VT_DATE to VT_BSTR? Pin
Anonymous13-Sep-05 20:47
Anonymous13-Sep-05 20:47 
Questionlock file Pin
wuz7313-Sep-05 20:30
wuz7313-Sep-05 20:30 
AnswerRe: lock file Pin
kakan13-Sep-05 23:54
professionalkakan13-Sep-05 23:54 
GeneralRe: lock file Pin
wuz7314-Sep-05 7:11
wuz7314-Sep-05 7:11 
GeneralRe: lock file Pin
kakan14-Sep-05 19:26
professionalkakan14-Sep-05 19:26 
QuestionRegistry wrapper class prevening writes to HKLM Pin
Chintoo72313-Sep-05 17:28
Chintoo72313-Sep-05 17:28 
I am wondering why this code works:

<br />
<br />
#include <windows.h><br />
#include <tchar.h><br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <winreg.h><br />
<br />
int main(int argc, char *argv[]) <br />
{<br />
<br />
<br />
   HKEY hk, hk2; <br />
   DWORD dwData, dwDisp; <br />
   TCHAR szBuf[MAX_PATH]; <br />
<br />
 <br />
   _snprintf(szBuf, sizeof(szBuf)-1, "SOFTWARE\\Microsoft"); <br />
 <br />
<br />
   if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, szBuf, <br />
          0, NULL, REG_OPTION_NON_VOLATILE,<br />
          KEY_READ, NULL, &hk, &dwDisp)) <br />
   {<br />
      printf("Could not create the registry key."); <br />
      return FALSE;<br />
   }<br />
 <br />
<br />
   if (RegCreateKeyEx(hk, "Windows", <br />
          0, NULL, REG_OPTION_NON_VOLATILE,<br />
          KEY_WRITE, NULL, &hk2, &dwDisp)) <br />
   {<br />
      printf("Could not create the registry key."); <br />
      return FALSE;<br />
   }<br />
 <br />
<br />
   LONG retValue = 0;<br />
   if ((retValue = RegSetValueEx(hk2,              // subkey handle <br />
           "TestWrite",        // value name <br />
           0,                         // must be zero <br />
           REG_EXPAND_SZ,             // value type <br />
           (LPBYTE) "data",        // pointer to value data <br />
           (DWORD) (sizeof("data"))))) // length of value data <br />
   {<br />
      printf("Could not set the value., error=%d", retValue); <br />
      return FALSE;<br />
   <br />
   }<br />
   <br />
<br />
   <br />
    return 0;<br />
}<br />



1. I was expecting RegSetValueEx to fail as the key "SOFTWARE\\Microsoft" is opened with KEY_READ. Is it not the case that RegCreateKeyEx succeeds only if the samDesired parameter is only a subset of the one its parent key object is created with?

2. I need to write a registry wrapper class that prevents writing to HKLM. Does any one have ideas what is the way to go about it? I was planning to clear off the (KEY_CREATE_LINK|KEY_CREATE_SUB_KEY|KEY_SET_VALUE) bits before calling RegCreateKeyEx when the key is HKLM but any RegCreateKeyEx opening any sub key doesnt seem to inherit the access mode of its parent. Appreciate any ideas in this regard.

Thanks in advance.
~f
QuestionFile transfer most efficient method Pin
Gochha13-Sep-05 17:05
Gochha13-Sep-05 17:05 
AnswerRe: File transfer most efficient method Pin
Hamed Musavi13-Sep-05 17:28
Hamed Musavi13-Sep-05 17:28 
AnswerRe: File transfer most efficient method Pin
Hamed Musavi13-Sep-05 17:30
Hamed Musavi13-Sep-05 17:30 
AnswerRe: File transfer most efficient method Pin
Laffis13-Sep-05 17:38
Laffis13-Sep-05 17:38 
AnswerRe: File transfer most efficient method Pin
ThatsAlok14-Sep-05 0:50
ThatsAlok14-Sep-05 0:50 
AnswerRe: File transfer most efficient method Pin
Bob Stanneveld14-Sep-05 1:06
Bob Stanneveld14-Sep-05 1:06 
QuestionVisual Studio Customization Pin
charlieg13-Sep-05 16:53
charlieg13-Sep-05 16:53 
QuestionCab file Pin
benjnp13-Sep-05 16:27
benjnp13-Sep-05 16:27 
AnswerRe: Cab file Pin
Christian Graus13-Sep-05 16:53
protectorChristian Graus13-Sep-05 16:53 
GeneralRe: Cab file Pin
benjnp13-Sep-05 17:57
benjnp13-Sep-05 17:57 
QuestionGlobal variable prob Pin
benjnp13-Sep-05 16:24
benjnp13-Sep-05 16:24 
AnswerRe: Global variable prob Pin
Weiye Chen13-Sep-05 16:41
Weiye Chen13-Sep-05 16:41 
GeneralRe: Global variable prob Pin
benjnp13-Sep-05 17:59
benjnp13-Sep-05 17:59 
GeneralRe: Global variable prob Pin
HumanOsc13-Sep-05 23:17
HumanOsc13-Sep-05 23:17 
AnswerRe: Global variable prob Pin
Christian Graus13-Sep-05 16:50
protectorChristian Graus13-Sep-05 16:50 
GeneralRe: Global variable prob Pin
Weiye Chen13-Sep-05 16:54
Weiye Chen13-Sep-05 16:54 
GeneralRe: Global variable prob Pin
benjnp13-Sep-05 18:05
benjnp13-Sep-05 18:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.