|
int RegWriteKeyValue(HKEY hKeyParent,CString strPath,CString strKey,CString strVal)
{
CRegKey regKey;
DWORD dwKeyCreateMode=REG_OPENED_EXISTING_KEY;
long lRes;
lRes=regKey.Create(hKeyParent,strPath,REG_NONE,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&dwKeyCreateMode);
if (lRes != ERROR_SUCCESS)
return 0;
lRes=regKey.SetValue(strVal,strKey);
if (lRes != ERROR_SUCCESS)
return 0;
// close the registry key
regKey.Close();
return 1;
}
RegWriteKeyValue(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce","Name","value");
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Thank u very much for ur help.
But it is in ATL. i dont want to use this in ATL.
once again thanks a lot. b'coz of ur reply i got an idea and i did it in SDK mixed with MFC to get my requirement.
Once again thank u very much.
ComputerNewton
|
|
|
|
|
use CRegKey of ATL classes.
God is Real, unless declared Integer.
|
|
|
|
|
Use the Win32 registry functions. Ugly, yes, but they work:
HKEY hNewKey = NULL;
DWORD disposition = 0;
DWORD error = ::RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\\Extensions\\Demo App", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hNewKey, &disposition);
char myString[] = "Some Data";
error = ::RegSetValueEx(hNewKey, "Some Value", NULL, REG_SZ, myString, sizeof(myString));
See MSDN on RegCreateKeyEx and RegSetValueEx for more info. (The code I provided is just a rough example... should compile and work but I can't be sure!)
Sometimes I feel like I'm a USB printer in a parallel universe.
|
|
|
|
|
Hi
I'm working on a fairly large file indexing system, and I'm trying to find the best and fastest way of finding out if a file needs reindexing.
Currently the best we've got is keeping a DB of the last time a file was indexed and periodically rescanning a checking the last modifed date against that.
Is there a way of being told if a file has been created or modified, in a similar sort of way to Visual Studio bringing up the "This file has been modified outside of Visual Studio..." dialog? (One which doesn't require a lot of resources as well - this is intended to run in the background)
Cheers
Dave
|
|
|
|
|
Check out 'FindFirstChangeNotification' in the Win32 documentation.
Paul
|
|
|
|
|
Cheers Paul
It's always the problem with trying to find where to start looking!
Dave
|
|
|
|
|
you can look here also:
UINT ThreadNotifyFunc (LPVOID pParam)
{
HWND hwnd = (HWND) pParam; // Window to notify
HANDLE hChange = ::FindFirstChangeNotification (_T ("C:\\"),
TRUE, FILE_NOTIFY_CHANGE_FILE_NAME ¦ FILE_NOTIFY_CHANGE_DIR_NAME);
if (hChange == INVALID_HANDLE_VALUE) {
TRACE (_T ("Error: FindFirstChangeNotification failed\n"));
return (UINT) -1;
}
while (...) {
::WaitForSingleObject (hChange, INFINITE);
::PostMessage (hwnd, WM_USER_CHANGE_NOTIFY, 0, 2);
::FindNextChangeNotification (hChange); // Reset
}
::FindCloseChangeNotification (hChange);
return 0;
}
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Also look for ReadDirectoryChangesW() .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
class a{
public:
a():rs(&db)
{}
CRecordset rs;//line a
CDatabase db; //line b
};
// my question is shld line b comes before line a
|
|
|
|
|
heu, you are trying to create an object, but you assign a member with another member of the same object, which wasn't set yet. so change your code...
i'd like to add a remark. your code is note very beautiful, and worse, it is not very useful.
put your data members in private statement, write your class definition in a .h file, and write the class implementation into a .cpp file :
A.h
<font style="color:blue;">class</font> CA {
CRecordset rs;
CDatabase db;
<font style="color:blue;">public:</font>
CA (<font style="color:blue;">void</font>);
<font style="color:green;">
}
A.cpp
CA::CA(<font style="color:blue;">void</font>) : rs(), db() {
}
<font style="color:green;">
TOXCCT >>> GEII power
|
|
|
|
|
i feel that was the most simple way to express his doubt.
It'd be funny to have .cpp and .h files along for such a simple question.
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
anyway, his code was wrong !
and you, i'm waiting for your response at your "who's who" page...
thx
TOXCCT >>> GEII power
|
|
|
|
|
check out, its there!!
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Members of class are constructed in order, in which are declared. It doesn't depend on, whether they are initialized in class constructor. And it also doesn't depend on the order of member initializers in class constructor.
So in your example the line b should be before the line a.
Robert-Antonio
"Life is very hard, if you apply E-R model to it."
|
|
|
|
|
Hi,
I created a thread using the AfxBeginthread function.
How do I stop this thread from another thread. MSDN resources say that its dangerous to use call TerminateThread. I tried using it too, but it failed to terminate it.
Thanks,
Deepak Samuel.
|
|
|
|
|
one way is to set a global boolean flag like g_fExit = true, from whichever thread you want ..so that the corresponding thread sees that and return.
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
in case you wanna use that call InterlockedIncrement or use a Critical section object in order to prevents more than one thread from using the same variable simultaneously.
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Check the CEvent for MFC or the events in general for WIN32
The main idea:
in the loop of the thread that you want to stop, call WaitForSingleObject with WAIT_OBJECT_0 on the event handle, and in case it is signaled you just have to return and in the other thread just signal the event
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
i told that was one way and perhaps the simplest.
see wot Jeffery Ricther has to say. [^]
"its easy to make complex and complex to make simple"
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Both are easy and simple to use, but i would rather go with events as it sure that it would be thread safe.
God is Real, unless declared Integer.
|
|
|
|
|
sounds nice..
please explain the need for thread saftey for this line:
g_fExit = true
that also with the help of an MFC object !
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
No, i am not tring to be within the context on this problem only... In general senario where threads need to be syncronised i would use kernel objects rather than some variables.;)
God is Real, unless declared Integer.
|
|
|
|
|
it 'd 'nt be fair if i dont mention the risk of deadlock. For any big and complex program it 'd be programmers nightmare to maintain all those handles.
if he has lot of threads and want to stop them form others. seems you didnt faced any such problem yet.
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
suhredayan® wrote:
if he has lot of threads and want to stop them form others
thats what kernel object are for, using it efficiently gives good results.
God is Real, unless declared Integer.
|
|
|
|