Discuss How to create a DWORD using C++? in the C/C++ Help forum on Dev Articles. How to create a DWORD using C++? C/C++ Help forum discussing building and maintaining applications in C/C++. Find out why these languages are the foundation on which other languages are built.
Posts: 8
Time spent in forums: 1 h 47 m 56 sec
Reputation Power: 0
How to create a DWORD using C++?
I've tried many different ways to write a program that ones opened, it will create a DWORD file in a registry folder and set the DWORD's value to 1- but I seem to be missing something because the complier won't let me compile it.
Can someone please write an example of a program like that so that I can see what I missed in some of the programs that I tried to write.
Thanks.
Posts: 1,030
Time spent in forums: 1 Week 12 h 34 m 39 sec
Reputation Power: 10
afaik, the best way is still to create a .reg file, and call regedit with that file using the system() call from C.
Search google to see how modifying the registry by means of .reg files works.
__________________ This is my code. Is it not nifty?
"The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools."
---Douglas Adams
Posts: 8
Time spent in forums: 1 h 47 m 56 sec
Reputation Power: 0
One more question.
If I wanted to write a program that creates a REG_SZ file, so I would write REG_SZ = This is a reg file (for example) instead of DWORD value = 1 and change REG_DWORD to REG_SZ and the sizeof(DWORD) to sizeof(REG_SZ)?
Thanks.
Posts: 600
Time spent in forums: 2 Days 22 h 40 m 27 sec
Reputation Power: 9
I haven't tried it, but to change to REG_SZ I would first try these steps:
-change DWORD value = 1; to probably LPCSTR value = "This is a registry key.";
-change REG_DWORD to REG_SZ in the RegSetValueEx function call
-the last parameter to RegSetValueEx is the length of the data, so change it to the actual length of the string, i.e. strlen(value) (or count the chars in value beforehand and add 1 for the null terminator)
-change the (BYTE*)&value to just (BYTE*)value since an LPCSTR is already a pointer (to some form of char)