|
In the continue with Steve see this[^] if its helpfuls
|
|
|
|
|
HI Experts
How can i handle the return value of this function
inline iRDOStoresPtr IRDOSession::GetStores ( )
{
struct iRDOStores * _result = 0;
HRESULT _hr = get_Stores(&_result);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return iRDOStoresPtr(_result, false);
}
manu
|
|
|
|
|
Try this
iRDOStoresPtr pRDOStores = IRDOSession::GetStores()
but replace the "IRDOSession::" bit the name of your variable that represents the IRDOSession class/structure, e.g.
iRDOStoresPtr pRDOStores = mySessions.GetStores()
|
|
|
|
|
Dear all,
Anybody knows from where AfxWinMain gets the CWinApp global object pointer ?
When i looked the MFC source file (winmain.cpp) i can see the following lines.
nt AFXAPI AfxWinMain(..../*params*/)
{
int nReturnCode = -1;
CWinThread* pThread = AfxGetThread();
CWinApp* pApp = AfxGetApp();
}
Surely AfxGetApp() returns that global object. me again looked the AfxGetApp function , it is calling a AfxGetModuleState state function and this function returns the CWinApp object. AfxGetModuleState gets this value from CThreadLocal class's object.
My question is How MFC getting the pointer of my CWinApp derived class object.
Share your ideas please..
-- modified at 0:51 Friday 5th January, 2007
If u can Dream... U can do it
|
|
|
|
|
The following line is from CWinApp::CWinApp :
pModuleState->m_pCurrentWinApp = this;
That's how it gets the app.
Steve
|
|
|
|
|
Thanks Steve. .
If u can Dream... U can do it
|
|
|
|
|
I'm trying to add a new string value to HKEY_LOCAL_MACHINE Software\\Microsoft\\Windows\\CurrentVersion\\run\\. I'm trying to give users a choice if they want to have the program start up with computer. I'm having some difficulty programming this with C++. Im using VC 7.1 on a windows XP. Ps. Using console. Any help would be greatly appreciated. Thanks in advance.
|
|
|
|
|
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.
|
|
|
|