|
Would you mind showing how to use this function? I'm using RegOpenKeyEX to get a handle to the key. Since RegGetKeySecurity requires a security descriptor, is there a way to get it from the handle? Thanks!
|
|
|
|
|
The RegGetKeySecurity function retrieves a copy of the security descriptor protecting the specified open registry key.
LONG RegGetKeySecurity(
HKEY hKey,
SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor,
LPDWORD lpcbSecurityDescriptor
);
Parameters
hKey
[in] Handle to an open key for which to retrieve the security descriptor.
SecurityInformation
[in] Specifies a SECURITY_INFORMATION value that indicates the <code>requested security information. </code>
pSecurityDescriptor
[out] Pointer to a buffer that <code>receives a copy of the requested security descriptor. </code>
lpcbSecurityDescriptor
[in, out] Pointer to a variable that specifies the size, in bytes, of the buffer pointed to by the pSecurityDescriptor parameter. When the function returns, the variable contains the number of bytes written to the buffer.
The above documentation clearly says how to do it. Did you look up the docs? Look at the statements marked in red.
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
Possible another way ..
<br />
if(ERROR_SUCCESS != RegOpenKeyEx(...))<br />
{<br />
DWORD LastError = GetLastError();<br />
<br />
TCHAR szBuf[80]; <br />
LPVOID lpMsgBuf;<br />
<br />
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,<br />
NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),<br />
(LPTSTR) &lpMsgBuf, 0, NULL );<br />
<br />
sprintf(szBuf, "Error %d: %s", LastError, lpMsgBuf); <br />
MessageBox(NULL, szBuf, "Error", MB_OK); <br />
LocalFree(lpMsgBuf);<br />
}<br />
HTH
Frank
|
|
|
|
|
Is there a way to make a combo box accept user input/data that is not listed in the list. For example, I have 10 and 20 in the list, can I have the user type in 80 in the dropdown list? I thought the dropdown style does this? Thanks.
|
|
|
|
|
Hello,
I would like to know what is the proper way to use LoadLibrary() when loading DLLs. In my project, it depends on couple DLL files to run. Those DLLs need to sit in Windows\win32\ or the same folder as the executable file. However, I want to put those DLL filew into some fixed place and when my application starts to run, I can load them to the memory. I try to use LoadLibrary() function but I don't know where should I call this function in the code. It is because everytime I start the program, I already get the "missing dll" error and the program get terminated before any code has been run. Any idea about this? Am I missing something?
Thanks!
Nacho
-- modified at 18:12 Tuesday 9th May, 2006
|
|
|
|
|
|
use LoadLibrary for load your dll and use GetProcAddress for functions in dll
and in the end use FreeLibrary
|
|
|
|
|
Colleagues,
I have a quick question.
I would think that the code pointed to by the arrow below would result in the IDR_MAINFRAME menu (and other resources) being displayed when the application starts. However, the IDR_PhotoOneTYPE menu and resources are loaded when the application starts. Is that because it just loads the first document template that is defined? If not, why is that?
Thanks in advance for any information you provide.
<br />
AfxEnableControlContainer();<br />
SetRegistryKey(_T("Local AppWizard-Generated Applications"));<br />
LoadStdProfileSettings(4);
pDocTemplate = new CMultiDocTemplate(IDR_PhotonOneTYPE,<br />
RUNTIME_CLASS(CPhotonOneDoc),<br />
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CPhotonOneView));<br />
if (!pDocTemplate)<br />
return FALSE;<br />
AddDocTemplate(pDocTemplate);<br />
pLWDocTemplate = new CMultiDocTemplate(IDR_MAINFRAME,<br />
RUNTIME_CLASS(CLyghtWayveDoc),<br />
RUNTIME_CLASS(CLyghtWayveFrm),<br />
RUNTIME_CLASS(CLyghtWayveView));<br />
if(!pLWDocTemplate)<br />
return FALSE;<br />
AddDocTemplate(pLWDocTemplate);<br />
<br />
CMainFrame* pMainFrame = new CMainFrame;<br />
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) <----------<<<<<br />
return FALSE;<br />
m_pMainWnd = pMainFrame;<br />
m_pMainWnd->DragAcceptFiles();<br />
EnableShellOpen();<br />
RegisterShellFileTypes(TRUE);<br />
CCommandLineInfo cmdInfo;<br />
ParseCommandLine(cmdInfo);<br />
if (!ProcessShellCommand(cmdInfo))<br />
return FALSE;<br />
pMainFrame->ShowWindow(m_nCmdShow);<br />
pMainFrame->UpdateWindow();<br />
return TRUE;<br />
<br />
-- modified at 16:41 Tuesday 9th May, 2006
|
|
|
|
|
Hi,
The application maintains a list(CPtrList) of document templates. When the application starts the document template availalbe at the head of the list is loaded.
The AddDocTemplate adds the template to the tail of the above said list.
So as per ur code... this list is like below
pDocTemplate->pLWDocTemplate
Bye,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
Thanks so much...
So what does the following statement do:
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
Again, thanks for your answer.
|
|
|
|
|
Hi,
This will be the default menu when no document is opened.
try to add the below line in the InitInstance() and see the difference.
Add the line
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
above this line in ur InitInstance()
if (!ProcessShellCommand(cmdInfo))
return FALSE;
Bye,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
Thank you so much. I really appreciate your answer.
|
|
|
|
|
Hello everyone, this is my first post here.
I have been fighting with a problem for quite some time now, and now i´m running out of time.
I have googled til i almost dropped dead
Well, to get to the point.
I have been designing a system for measuring times and speeds for use at Drag Racing competitions. im am doing it as my final year project (thesis) at my school, the Swedish Polytechnic in Finland.
Used tools:
Visual Studio 6 pro, Access 97.
VC++ / MFC, ADO.
I have designed a dialog, on this dialog i have a bunch of editboxes. The idea is that the users types a number in one of the boxes. This number is a id for a competitor. i want to fetch data about this competitor and fill the other editboxes with that data. For example the make, model and engine size of the car.
I already added the Microsoft ADO Datacontrol and hooked up a dbcombo to it. That works ok, i can scroll data with the Data control. But this is not the way i want users to enter data. The users have a paper which contains the "ladder" so they just need to enter the number of the lefthand conpetitor and then the righthand.
I tried experimenting with the find method of the Crecordset class, but that is not going very well, as visual studio wont give me the memberfunctions as i usually does.
I have coded a bit of databases in Delphi and i must say that it is much easier But i like C++ and have to stick to it because speed is very important in this case.
How do i accomplish the above?
Please somebody help me out, we are testing on saturday and i don´t want to think about what will happen if i´m not ready
Thanks in advance!
-- modified at 9:11 Wednesday 10th May, 2006
Please, pretty please respond someone
P.S Later in i need to save the contents of two double[8] arrays to another table. Is there a simle way to run pure sql?
|
|
|
|
|
How to get Activex controls Version? throught MFC
Fly Like An Eagle With MIGHTY POWER.
|
|
|
|
|
hi,
u have to set version for activex control.
just include file version and product version in Version folder in resources.
cheers
sangeet
-- modified at 1:36 Friday 12th May, 2006
|
|
|
|
|
How to get Activex controls Version? i am using on my
Fly Like An Eagle With MIGHTY POWER.
|
|
|
|
|
Hi,
Can anyone supply sample code that can get/set the state of the
"Hide extensions for known file types" check box, which is in control panel "Folder Options".
Many thanks.
|
|
|
|
|
Check out HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced in the registry.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Thanks David your advice was very helpful. Although it hasn't entirely solved my problem, which is in code similar to this.
<br />
CFileDialog D;<br />
<br />
if( D.DoModal() == IDOK )<br />
{<br />
CString strFPN = D.GetFileName();<br />
CString strExt = D.GetFileExt();<br />
<br />
CString strFPNandExt = strFPN + strExt;<br />
<br />
}<br />
My problem is that when explorer is hiding file extensions, CFileDialog::GetFileExt() returns a null string.
So what I really need to know is whether there is a way to get the file extension of a file that is selected in CFileDialog, (or maybe anywhere in the shell) when file extensions are hidden.
I don't really want to have a registry value changed and then restored
when CFileDialog::DoModal() has finished its business.
|
|
|
|
|
Atom wrote: So what I really need to know is whether there is a way to get the file extension of a file that is selected in CFileDialog, (or maybe anywhere in the shell) when file extensions are hidden.
See here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Superb, just what I need.
Many thanks.
|
|
|
|
|
Hey! I have a chip card reader and some tools with it. this is the reader >>> http://www.chipdrive.de/cgi-bin/edcstore.cgi?user_action=list&category=Produkt;02_L%F6sungen;04_SC%20Tools;05_Screenshots
4th picture is where i should be programming and editing script... i think the script is in pascal language but some friend say that it could be programmed ba C++ too. Well i don't know really nothing about this....... i got this in school and have to done this by friday.
what i have to do is to programme some program which would do something like: showing my grades...
its like that... when you put chip card in reader it should pop-up new window when i would enter code... and another window would open where i would see my grades.... i would really need that!!!! please someone help me!!!!!!!!!
this is reader >>> http://www.chipdrive.de/cgi-bin/edcstore.cgi?category=Produkt;03_Chipkartenleser&user_action=detail&catalogno=P208199
this is software >>> http://www.chipdrive.de/cgi-bin/edcstore.cgi?user_action=list&category=Download%3B03_Software (the last one)
and a chip card - 256kb EEPROM
I2C protokol
brane
|
|
|
|
|
I'm really a beginner of this program,visual c++, so I'm loooking for someone that could help me.
I have to draw a pixel on the screen and I have to find its coordinates because then I'll have to move this point using(maybe) a for loop.
Thanks...and sorry for my english
Baile79
|
|
|
|
|
baile79 wrote: I have to draw a pixel on the screen and I have to find its coordinates...
This is a bit unclear. In order to render the pixel on the device, you must know it's x,y values. There shouldn't be any need to find anything.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Solved: The issue had something to do with recursing the end process function. I changed how the recursion worked and everythings fine now!
I'm writing a program to remove certain spyware. To do this it needs to get a filename and path from a clsid, possibly end a process, delete the file, and delete the clsid. The problem is, if it ends a process then the clsid variable goes from storing a clsid (eg. {00000000-0000-0000-0000-000000000001}) to having odd characters like: ↑▼% (I hope those show up. It's a cross, an upside down triangle, and a %).
This *only* happens if the code kills a process. Here's the function that searches the registry after being passed a clsid:
int delClsId(char *clsid)<br />
{<br />
HKEY keyHandle,key2,key3;<br />
char rgValue[1024];<br />
char fnlRes [1024];<br />
DWORD size1;<br />
DWORD Type;<br />
<br />
cout << "Reading key " << clsid << endl;<br />
<br />
if (RegOpenKeyEx(HKEY_CLASSES_ROOT,_T("CLSID"),0,KEY_ALL_ACCESS, &keyHandle) == ERROR_SUCCESS)<br />
{<br />
size1=1023;<br />
RegOpenKeyEx(keyHandle,clsid,0,KEY_ALL_ACCESS, &key2);<br />
cout << "Opening InProcServer32 in key " << clsid << endl;<br />
if (RegOpenKeyEx(key2,_T("InProcServer32"),0,KEY_ALL_ACCESS, &key3) == ERROR_SUCCESS)<br />
{<br />
if (RegQueryValueEx(key3,_T(""),NULL,&Type,(LPBYTE)rgValue,&size1) == ERROR_SUCCESS)<br />
{<br />
sprintf_s(fnlRes,"InProcServer32 is: %s",rgValue);<br />
cout << fnlRes << endl;<br />
delFile(rgValue);<br />
cout << "CLSID is " << clsid << endl;<br />
}<br />
RegCloseKey(key3);<br />
}<br />
<br />
if (RegDeleteKey(key2,_T("InprocServer32")) == ERROR_SUCCESS){<br />
cout << "Removed InprocServer32 Key!" << endl;<br />
} else if (RegDeleteKey(key2,_T("InprocServer32")) == ERROR_FILE_NOT_FOUND){<br />
cout << "Couldn't locate InprocServer32 key." << endl;<br />
} else {<br />
cout << "Failed to Remove InprocServer32 Key" << endl;<br />
}<br />
RegCloseKey(key2);<br />
<br />
<br />
}<br />
else strcpy_s(fnlRes,"Couldn't access system information.");<br />
<br />
RegCloseKey(keyHandle);<br />
<br />
char delKey[45];<br />
sprintf_s(delKey, "CLSID\\%s", _T(clsid));<br />
cout << delKey << endl;<br />
int i = 1;<br />
<br />
do{<br />
i = delRegKey(HKEY_CLASSES_ROOT, delKey);<br />
} while (i == 1);<br />
<br />
return 0;<br />
}<br />
From the function for killing the process I've narrowed the problem down to something that happens in the "if" part of this if/else statement:
<br />
if(TerminateProcess(hProc,0))<br />
{<br />
CloseHandle(hSnapShotm);<br />
CloseHandle(hSnapShot);<br />
CloseHandle(hProc);<br />
FreeLibrary(hInstLib);<br />
return 0;<br />
}<br />
else<br />
{<br />
CloseHandle(hSnapShotm);<br />
CloseHandle(hSnapShot);<br />
CloseHandle(hProc);<br />
FreeLibrary(hInstLib);<br />
return 602;<br />
}<br />
If the process isn't running, or there's no process to kill then there's no problem. Also, I realize usually you'll find dll files here, but I wanted to test how all these things would work together and would love to understand what's going on. I'm pretty new to c++ but have a strong programming background and large working knowledge of the registry. Thanks!
-- modified at 1:02 Wednesday 10th May, 2006
|
|
|
|
|