|
If you ship release binaries to the customer your code will be optimised and therefore using the pdb file will make no sense. In the past I've logged a callstack to a file when an unhandled exception has occurred by setting a hook into the kernel exception handler the walking the stack. Doing this can give you a stack in hex (though functions are often missing due to optimisation). You can then decode the stack information using a map and cod files generated at build time giving you the line in the code that caused the exception.
|
|
|
|
|
|
BOOL checkExistence(HKEY *hKey, LPCTSTR lpszAppName)
{
CRegKey regKey;
if( regKey.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"),
KEY_READ) != ERROR_SUCCESS )
return FALSE;
DWORD dwIndex = 0;
DWORD cbName = 128;
TCHAR szSubkeyName[128];
CString strSubkeyName;
int nHasAllItems = 0;
while( regKey.EnumKey(dwIndex, szSubkeyName, &cbName) != ERROR_NO_MORE_ITEMS )
{
dwIndex++;
cbName = 128;
strSubkeyName.Format(_T("%s"), szSubkeyName);
if( strSubkeyName.Compare(lpszAppName) )
{
nHasAllItems++;
continue;
}
else
break;
}
regKey.Close();
if( nHasAllItems == dwIndex )
return FALSE;
else
{
*hKey = regKey.m_hKey;
return TRUE;
}
}
I wrote this funx to check whether there's a particular installed app in the registry. After calling this funx, hKey is expected to be assigned the registry handle. But prob occurs as Ive indicated above.
|
|
|
|
|
How are you calling checkExistence() ?
Krauze wrote: strSubkeyName.Format(_T("%s"), szSubkeyName);
What's wrong with:
strSubkeyName = szSubkeyName;
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I mean:
*hKey = regKey.m_hKey;
Prob occurs here.
|
|
|
|
|
How are you calling checkExistence() ?
Aso, have you considered something a little more manageable, like:
BOOL checkExistence( HKEY *hKey, LPCTSTR lpszAppName )
{
CString strKey;
strKey.Format(_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s"), lpszAppName);
return RegOpenKey(HKEY_LOCAL_MACHINE, strKey, hKey) == ERROR_SUCCESS;
}
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
In fact Ive tried this method later. And it works perfectly.
|
|
|
|
|
"hKey is expected to be assigned the registry handle."
but how as you did regKey.Close(); before *hKey = regKey.m_hKey; ??
Try
*hKey = regKey.Detach(); Remeber to call RegCloseKey() on the obtained handle once finished using it.
modified on Wednesday, July 28, 2010 1:30 AM
|
|
|
|
|
regKey.Close();
*hKey = regKey.m_hKey;
after closing the key the handle is invalid. You really shouldnt do that
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi,
I have MFC dialog app and there is hosted WindowsFormsControl.
In MFC app it is declared as: CWinFormsControl<windowsformscontrollibrary1::usercontrol1> m_ctrl1;
Could somebody explain me why I can use it as a pointer: m_ctrl1->textBox1 and as a object: m_ctrl1.GetControl()
|
|
|
|
|
See CWinFormsControl is a template class.
template<class TManagedControl>
class CWinFormsControl : public CWnd
It has the -> operator overloaded to return TManagedControl.
inline TManagedControl^ operator->( ) const;
Then m_ctrl1->textBox1 will be TManagedControl->textbox. Also, GetControl() is a method of CWinformControl and it gets called when you use m_ctrl1.GetControl().
inline TManagedControl^ GetControl( ) const;
http://msdn.microsoft.com/en-us/library/7f8b5xd9(v=VS.80).aspx[^]
|
|
|
|
|
Thank you for explanation.
|
|
|
|
|
Hello,
Does anyone know how I might handle file inputs to my MFC program? So basically say windows is configured to launch my app for files with a given extension. What do I need to do in MFC so that I can get the path to the file and process it accordingly?
Many thanks,
Keith
|
|
|
|
|
All that you should do is check out HKEY_CLASSES_ROOT. And write the handler for command lines that are transferred to your app when opening the files.
|
|
|
|
|
|
See some of the suggested solutions here[^].
Broadly speaking the filename is passed to your application as a command line (text string) and you need to parse the string to find the filename and any optional parameters you may accept.
It's time for a new signature.
|
|
|
|
|
If your app was created via the MFC wizard, all of the pieces should already be in place. If not, check out EnableShellOpen() and RegisterShellFileTypes() .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I am making a text editor in C++ and want it to save rtf an txt files. I have made a rich text box called richTextBox1, a toolstrip button called ToolStripButton1 and a save file dialog called saveFileDialog1. I need the save file dialog to save the contents of the rich text box when the tool strip button is clicked. Here is my code so far:
private: System::Void toolStripButton11_Click(System::Object^ sender, System::EventArgs^ e) {
saveFileDialog1->Filter="Text File|*.txt|Rich Text Document|*.rtf|All Files|*.*";
saveFileDialog1->Title="Save As";
this->saveFileDialog1->ShowDialog();
}
How do I make the dialog save the contents of the rich text box?
|
|
|
|
|
Hi,
the saveFileDialog is a dialog, it communicates with the user, it does not save a thing. Your code has to perform the necessary save actions upon the user's choices. So check for the dialog result, and if "OK", save the data yourself to the selected file.
|
|
|
|
|
mmagill0 wrote: How do I make the dialog save the contents of the rich text box?
You don't; the dialog merely gives the user the opportunity to select the destination file where the data will be saved. Your program then has to write the data into that file in the format relevant to the file type.
It's time for a new signature.
|
|
|
|
|
so how do I use the information returned from the dialog to save the file?
|
|
|
|
|
If ShowDialog() returns DialogResult.OK , use saveFileDialog1->FileName to open file file and write the contents.
|
|
|
|
|
mmagill0 wrote: so how do I use the information returned from the dialog to save the file?
The only information you have from the dialog is the file name and destination directory. From this you create the file and write your data to it, the dialog has no further influence on this process.
It's time for a new signature.
|
|
|
|
|
In addition to what's already been suggested, you might receive more help by posting to the correct forum.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
if i'm using winforms with C++, do I post in winforms or C++??
|
|
|
|