|
You have a problem but what?
|
|
|
|
|
would it be possible for somebody to give me an example on how I would do this kind of registry editing?
|
|
|
|
|
|
arbster wrote: I'm having some difficulty programming this with C++. Im using VC 7.1 on a windows XP
What difficulty you are facing ?
|
|
|
|
|
to be honest i know what the functions exist but I'm having trouble implementing them. An example would help greatly.
|
|
|
|
|
arbster wrote: An example would help greatly.
This example would create a key named "arbster" under HKLM->System in the registry.
HKEY hKey;
DWORD dwMyVal;
if ( RegCreateKeyEx(HKEY_LOCAL_MACHINE,
_T("SYSTEM\\arbster"), 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_WRITE,
NULL, &hKey, &dwMyVal) == ERROR_SUCCESS )
{
AfxMessageBox(_T("Key created successfully"));
}
else
AfxMessageBox(_T("Unable to create key"));
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
Use RegOpenKeyEx() and open the key and then use RegSetValueEx() to write into it. You may also want to look into the documentation for CRegKey.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
what if the key does not exist (im trying to add a key). Will RegOpenKeyEx() still work or will i have to use RegCreateKey() ?
|
|
|
|
|
RegOpenKeyEx() is used to open an existing key. For adding a key, use RegCreateKey or RegCreateKeyEx(). Have a look at Registry Functions[^] in MSDN.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
Just to add on, you probably want to create your registry entry under HKEY_CURRENT_USER instead, so that any changes will not affect other users accounts on that same machine.
<font=arial>Weiye Chen
Give me the Death Note, and I'll cleanse the world...
|
|
|
|
|
Take a look at this article, it's poorly written but the class is decent and works.
Adding your application to the Windows Startup[^]
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
arbster wrote: +. Im using VC 7.1 on a windows XP. Ps. Using console. Any help would be greatly appreciated. Thanks in advance.
Try CRegkey , include <atlbase,h>
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
If we select GS option, what else we should do?
Is error handler a must?
What is the effect of selecting GS without having error handler?
Thanks & Regards,
Suman
|
|
|
|
|
This[^] link will help you.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
Dear All,
How can i start my ATL Service program that is done by VC 6.0 as a Windows Service ?
Kindly Help me.
Thanks
-- modified at 0:08 Friday 5th January, 2007
Nice things do nice works
|
|
|
|
|
Hello Sakthiu,
First of all you must register that service.
Then, once it is registered, you can go to the [start menu]->[Setup]->[administrative tools]->[Services] and start the desired service.
You can find information here in the CP in order to register a service.
Hope this helps.
|
|
|
|
|
|
And also a little bit of code...
inline BOOL CServiceModule::Install()
{
if (IsInstalled())
return TRUE;
SC_HANDLE hSCM = ::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (hSCM == NULL)
{
MessageBox(NULL, _T("Couldn't open service manager"), m_szServiceName, MB_OK);
return FALSE;
}
TCHAR szFilePath[_MAX_PATH];
::GetModuleFileName(NULL, szFilePath, _MAX_PATH);
SC_HANDLE hService = ::CreateService(
hSCM, m_szServiceName, m_szServiceName,
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,
SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,
szFilePath, NULL, NULL, _T("RPCSS\0"), NULL, NULL);
if (hService == NULL)
{
::CloseServiceHandle(hSCM);
MessageBox(NULL, _T("Couldn't create service"), m_szServiceName, MB_OK);
return FALSE;
}
::CloseServiceHandle(hService);
::CloseServiceHandle(hSCM);
return TRUE;
}
inline BOOL CServiceModule::Uninstall()
{
if (!IsInstalled()) return TRUE;
SC_HANDLE hSCM = ::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (hSCM == NULL)
{
MessageBox(NULL, _T("Couldn't open service manager"), m_szServiceName, MB_OK);
return FALSE;
}
SC_HANDLE hService = ::OpenService(hSCM, m_szServiceName, SERVICE_STOP | DELETE);
if (hService == NULL)
{
::CloseServiceHandle(hSCM);
MessageBox(NULL, _T("Couldn't open service"), m_szServiceName, MB_OK);
return FALSE;
}
SERVICE_STATUS status;
::ControlService(hService, SERVICE_CONTROL_STOP, &status);
BOOL bDelete = ::DeleteService(hService);
::CloseServiceHandle(hService);
::CloseServiceHandle(hSCM);
if (bDelete)
return TRUE;
MessageBox(NULL, _T("Service could not be deleted"), m_szServiceName, MB_OK);
return FALSE;
}
Hope this helps.
I think I've missed the name, you must not register the service, you must install it before being able to start it.
|
|
|
|
|
I am using VC++ 6.0
The Visual Studio documentation states unequivocally:
Declarations of pointers to structures and typedefs for structure types can use the structure tag before the structure type is defined
Then
A member cannot be declared to have the type of the structure in which it appears. However, a member can be declared as a pointer to the structure type in which it appears as long as the structure type has a tag. This allows you to create linked lists of structures
I have two structures containing pointers mutually to each other, one of them containing a chaining pointer to itself as well.
I receive very strange syntactical error messages in the references to these pointers, for example referring to some left bracket, "(", (not present in the reference) and alike.
I tried with an incomplete definition, like
struct anystructure;
before the structure using the other, but it did not help. The error messages slightly change, but that's it.
Is this a known problem?
|
|
|
|
|
What's the error message ?
Yes, any type you can have as a pointer before it's declared, but it needs to be declared before you *use* the pointer. The point ( no pun intended ) is that the compiler can allocate space for a pointer before knowing how big the object is, but it can't access the object before it knows about it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I guess your "The point ( no pun intended ) is that " is meant "The point ( no pun intended ) is NOT that ".
The declarations are in headers, far before the actual references. Other fields of the same structures can be referenced.
|
|
|
|
|
No, I meant what I said. The compiler can allocate a pointer before knowing what it's pointing to, but it can't use an object it knows nothing about.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
OK, I understand how you meant "the point". That's all trivial, as a pointer is always four bytes long, at least with VC6.
As I indicated in my original post, all declarations are ahead.
|
|
|
|
|
Vancouver wrote: That's all trivial, as a pointer is always four bytes long, at least with VC6.
Yeah, that was my point.
Vancouver wrote: As I indicated in my original post, all declarations are ahead.
OK, then you have a different problem, which we can't help you with, without seeing the code.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Can you post code causing "very strange syntactical error messages " and maybe the struct
definitions including the relevent circular reference?
Mark
|
|
|
|