| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
Sorry, I can't help; I have no idea.
Costas |
|
#3
|
||||
|
||||
|
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 Join the Itsacon fanclub! Zero Tolerance: Spammers banned so far: 280
![]() |
|
#4
|
|||
|
|||
|
Quote:
Why didn't I think of that. Thats a great idea, thanks. |
|
#5
|
||||
|
||||
|
You're welcome. Good luck :-)
|
|
#6
|
|||||
|
|||||
|
C Code:
Creates a key under HKCU\My_Subkey\MyKey\ThisIsADword with type REG_DWORD and value 1. I'm on WinXP SP2 using Dev-C++. |
|
#7
|
|||
|
|||
|
Quote: Thanks. |
|
#8
|
|||
|
|||
|
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. |
|
#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) |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > How to create a DWORD using C++? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|