|
nothing is so clear anywhere
it is recommended to call DefWindowProc after every
message you handle. But some times it is not a good idea.
suppose we want to override the look of a control in this case if we update the look ourself and then call DefWindowProc it will overwrite over operation.
so calling the default here not a good idea.
just remember that window functionality must not suffer.
otherwise Windows will get angry.
|
|
|
|
|
Hi.
I'm writing an application that it connects with a SQL database using ADO, and in many places it execute store procedures, but there is a routine that it doesn't work. This is the portion of code with the bug.
<br />
<br />
...<br />
Cmd->PutRefActiveConnection(pAdoCone);<br />
<br />
Cmd->CommandText = "ProductsInOrders";<br />
Cmd->CommandType = adCmdStoredProc;<br />
<br />
vtidProduct.vt = VT_I4;<br />
vtidProduct.intVal = (int)idProduct; <br />
<br />
paramID = Cmd->CreateParameter ("ProdID",adInteger,adParamInput,sizeof(int),vtidProduct);<br />
<br />
paramID->Value = vtidProduct;<br />
<br />
Cmd->Parameters->Append(paramID);<br />
<br />
Rs = Cmd->Execute(&vtMissing, &vtMissing, adCmdStoredProc); <br />
<br />
m_lstOrders.ResetContent();<br />
<br />
while (!Rs->adoEOF)<br />
{<br />
idOrder = Rs->GetFields()->GetItem("OrderID")->Value.iVal;<br />
<br />
data.Empty();<br />
<br />
data.Format("%i", idOrden); <br />
<br />
m_lstOrders.AddString (data);<br />
<br />
<br />
Rs->MoveNext(); <br />
}<br />
...<br />
Well, it looks like the store procedure return 0 records, that's why the flow never enter the while, but I test the SP in SQL, (SQL 2000), and it works, and there is more, I wrote a little VB 6.0 application to test the SP and it works too!!. So, there's something wrong, (maybe is something stupid but I can't see it now, I'm blind!). Debugging, I can see right values for the parameter idProduct, I think the Execute method is wrong, because everything goes well until that line, then I get an empty recordset.
If someone see what is wrong, I will really appreciate any suggestion.
Thanks.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Hi,
I hawe a problem writing registry keys and values in registry under current user that has not administrator rights. We have an application that must work under common user priveleges but must install it under adin rights because we must register some activeX components. Is there a Way to write registry entries from one user to another. In some instalations I saw some options that say "use settings for all users"... if those settings are writen in the registry how can I access them and where are they stored.
I'm working in VS.NET 2002 in MFC.
Thanks in advance.
|
|
|
|
|
Just doing a quick peek, and you could use LogonUser , ImpersonateLoggedOnUser , etc.
Or CreateProcessWithLogonW...
You'd need the adminish name & password. But unless you knew them, you shouldn't be fiddling with HKLM anyway. That's the whole point of user security...
Iain.
|
|
|
|
|
Raul Simcic wrote: I saw some options that say "use settings for all users"... if those settings are writen in the registry how can I access them and where are they stored.
The area for common user data is [driveletter]:\Documents and Settings\All Users folder.
This doc explains in detail where you "should" store configuration stuff.
See section 3.0 Data and Settings Management
Designed for Windows XP Application Specification[^]
Maybe this will help you, maybe not
Mark
|
|
|
|
|
Typical practice with the registry is to store per-user settings under HKEY_CURRENT_USER\Software\<Company Name>\<Application Name> , and per-application (or 'all users') settings under HKEY_LOCAL_MACHINE\SOFTWARE\<Company Name>\<Application Name> .
The one difficulty with using the HKEY_LOCAL_MACHINE subkey is that normally, non-privileged users do not have write access to that part of the registry. You can have your installation modify the access control list to allow it, however.
Raul Simcic wrote: Is there a Way to write registry entries from one user to another
This is not something you want to do. What happens when users are added to or removed from a machine?
Software Zen: delete this;
|
|
|
|
|
Hi All,
I came across to a problem with the new Windows Vista - RC2, while using RegCreateKeyEx. I have a small function that sets a DWORD value to the Registry. It works fine on XP, but recently I used the Vista OS and I get an "Access Denied" Error (5).
Looking around the net I read about having to set the "access descriptor" within the SECURITY_ATTRIBUTES before passing to RegCreateKeyEx. But I haven't been able to find an example of doing that, or any other solution to my problem.
Forgot to mention: The error occurs when I try to set the ClearPageFileAtShutdown key to 1 within the HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Session Manager\Memory Management.
#####################################################################
Here is the function that Im using:
LONG WriteRegDWORD( HKEY hKey, _TCHAR* sSubKey, _TCHAR* sKeyValueName, DWORD dwKeyValue )
{
DWORD dwDisp = 0;
SECURITY_ATTRIBUTES saSecAttr = {0};
HKEY hKeyHandle = NULL;
LONG Res = 0;
Res = RegCreateKeyEx( hKey, sSubKey, 0, _T(""), 0, KEY_ALL_ACCESS, &saSecAttr,
&hKeyHandle, &dwDisp );
if( Res == ERROR_SUCCESS )
{
Res = RegSetValueEx( hKeyHandle, sKeyValueName, 0, REG_DWORD, (LPBYTE)&dwKeyValue,
(DWORD)sizeof(DWORD) );
if( Res != ERROR_SUCCESS )
{
_tprintf(_T("ERROR: %d \n"), Res );
}
RegCloseKey(hKeyHandle);
}
else
{
_tprintf( _T("ERROR: %d \n"), Res );
}
return Res;
}
#####################################################################
If anyone has a suggestion or solution to my problem I will highly appreciated.
Thank you,
Nick
-- modified at 7:38 Friday 20th October, 2006
|
|
|
|
|
This should help.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thank you DavidCrow,
But unfortunately this example didn't help.
To be more precise to the particular example, the call to RegOpenKeyEx returns "access denied" under Windows Vista RC2 when trying to open key HKEY_LOCAL_MACHINE, System\CurrentControlSet\Control\Session Manager\Memory Management.
Thank you,
Nick
|
|
|
|
|
Nick_Chr wrote: But unfortunately this example didn't help.
Why?
Notice how the SECURITY_ATTRIBUTES variable, sa , is populated prior to calling RegCreateKeyEx() . That's what you need to do. You may not need all of that code, but the general idea is definitely there.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Never ever use KEY_ALL_ACCESS . Pass only the privs you need, in this case KEY_SET_VALUE .
|
|
|
|
|
Thank you DavidCrow and Michael Dunn for your answers.
I managed to find the solution to the problem. Apparently Vista is using a new security component named User Account Control (UAC). When it is switched on you have to ask for permision to have full access from the user.
I don't know how right or wrong my solution is, but what I found is to use a wrapper executable file that executes my main app. To do this I used the ShellExecute call passing as operation the "RunAs" keyword. Doing this it asks for permision to run my main app, and from there my first code worked as in XP without any problems...
Thank you again for your help.
Nick...
|
|
|
|
|
I HAVE TO write a programm that can erase all data from hard drive
that no one can recover it again.There are planty of algorithms that can do
that and I wanna use them in my programm.I have to write it for my exam pro
ject at university. Any help?? PLIZ...sorry for my English couse i`m not Pol
ish.
|
|
|
|
|
Buy a big hammer!
Seriously, you'll struggle to really delete everything (since the OS will need some kind of access to the drive) - Do you want to kill off the FAT/NTFS tables, MBR, etc, too?
Most file shredders work by opening the file to be destroyed, and just overwriting it with random data multiple times. Repeat for each file you want to get rid of. This should be achievable in a few dozen lines of code. If you've already deleted all the files, then you'd just need to create a single file that fills the entire capacity of the drive, and keep writing garbage to that, until you're happy (run it a few times, then see if you can make undelete tools work)
|
|
|
|
|
benjymous wrote: Buy a big hammer!
If the data is truely that sensitive that one has to go to those extremes then a hammer will not be good enough, one can always read the data off the bits of pieces left over. The best way to truely destroy the drive is to open it up and melt down the disk platter so all that is left is a puddle of molten metal.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Bah. No doubt there's someone out there who could restore it to its original form.
Dump it into the supermassive black hole at the center of our galaxy.
Software Zen: delete this;
|
|
|
|
|
Now, lets not go to extremes. Shooting it into the sun should be good enough.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
If you have an algorithm whats problem?
|
|
|
|
|
Is formatting the drive an option?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
No, it is`nt i would be too easy :/ some guys with some cool programms can recover any data even after formatting. Formatting the hard drive just create another allocation table, but if you want to you can find many ways (or shareware ) programs) to get the data back :/ it could be a part of my programm...formatting the hard drive...but the most important is that i want to use my small programm: delete some or all data from hdd and then use one of many well known programms for recovering deleted data and just show that would be impossible thanks to my application or script whatever...i`m still looking for someone who was doing simillar stuff and have those working algorithms. but thanks a lot guys...that were really thunder speed answers
|
|
|
|
|
plzz can anyone tell
how can we switch the values of two variables without using a 3rd variable in C
Thanx
Maryum
|
|
|
|
|
int i,j;
i =2 ;
j= 3;
i = i + j;
j = i - j ;
i = i -j;
I guess this is interview question.
-- modified at 7:22 Friday 20th October, 2006
|
|
|
|
|
Why?
Sounds like a homework question again.
Try Google[^]
|
|
|
|
|
thanx for ur help actually someone asked me that question and i did'nt know that its possible.
thanx again
bye
Maryum
|
|
|
|
|
No, you can't.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|