|
Hi,
I use Visual C++ 6.0 SP 4 , SQL Server and oledb
I create a class to connect to my database. In my constructor i initialize com library like this :
CoInitialize(NULL);
In my destructor i release com library like this :
CoUninitialize();
If i use this class to execute for exemple an sql query ( store procedure), my functions open, execute, close,... work.
But if i close my application ( OnOK ) , two seconds later i obtain the following acces violation message :
EXCEPTION(c0000005 acces,@40f919) EBP184f0b8 EIP40f919)
ASM 45 fc 8b 08 8b 01 52 ff 50 08 8b e5 5d c3 cc cc cc cc cc cc
EAX:184f618 EBX:dc0110 ECX:383439 EDX:383439 ESI:dc0064 EDI:184f664 ESP:184f0b4
The suspect function is _Release() throw() which is in a Visual C++ include file ( in Include\COMIP.H )
// Releases only if the interface is not null.
// The interface is not set to NULL.
void _Release() throw()
{
if (m_pInterface != NULL) {
m_pInterface->Release();
}
}
But if i comment out CoUninitialize() instruction, my code work without acces violation.
Can anybody help me?
Best regards,
Cheickna
|
|
|
|
|
If you are using MFC, MFC will quitely do COInitialize() and CoUninitialize()
for you. This may be a source of problems (calling things twice). The docs
say you should prefer CoInitializeEx() over CoInitialize().
If you are using the IMallocSpy interface be sure to deregister your
spy before destroying it.
Don't know if that helps, but I've seen problems with these areas.
Stephen Kellett
|
|
|
|
|
Hi,
I faced some problem when develop a small Internet reliant application, could you help me to solve them ?
How to use get/put_onsubmit method of interface IHTMLFormElement when hosting a WebBrowser control in an
application ?
How to hosting more than one WebBrowser control in an application, which use same session on the server ? Once the
session is authenticated by first created control, other controls can enlist in the same session.
Thank you.
|
|
|
|
|
|
|
I have the
_bstr_t *alt;
BSTR *restxt;
HOW COULD I PUT THE VALUE OF _bstr_t in restxt??????
Thanks and BEST REGARDS!!!!
Javier.
|
|
|
|
|
|
In my application I wanted to add "e-notes" functionality = the possibility to create/edit/delete the electronical equivalent of the well known Post-It notes.
So, every note is presented as a modeless, scalable note dialog containing one big rich edit control. (besides two static controls for displaying the date/time and the author)
Now, I have two problems with them:
1) I want the content of the rich edit control to be saved whenever the note dialog loses
focus (cf. the notes in Outlook)
But neither the handler function for the WM_KILLFOCUS message for the dialog
nor the handler function for the NM_KILLFOCUS message for the rich edit control
is triggered when e.g. I switch between two notes.
Only when I close the dialog the WM_KILLFOCUS handler function is triggered.
How come? How should I implement the desired behaviour?
2) A typical behaviour of such 'notes' is the possibility to show them 'always on top'.
I know the function to set that:
SetWindowPos(&wndTopMost,NULL,NULL,NULL,NULL,SWP_NOMOVE|SWP_NOSIZE|SWP_NOOWNERZORDER);
and it works.
But how do I reset that behaviour WITHOUT influencing the other note dialogs?
e.g. - I have successfully set 4 note dialogs to be always on top
- I choose to reset the behaviour from note 3:
SetWindowPos(&wndBottom,NULL,NULL,NULL,NULL,SWP_NOMOVE|SWP_NOSIZE|SWP_NOOWNERZORDER);
- Sometimes all other notes loose their 'always on top' behaviour,
sometimes some of them notes do. The behaviour seems to be unpredictable.
Can someone help me out?
Thanks in advance.
Geert Delmeiren.
|
|
|
|
|
I was trying to deploy a web service developed using managed C++.
Its nothing but adding two nos.. thought of starting with the simpler one.
However, I have a strange problem. Once after deploying the web service, I was not able to make any changes to my web service. If I add a new function or make some modifications to the function, the compiler refuses to link saying that it couldnt delete the (.pdb) file.
Also complains that some other process may be using the resource.
So, even if i stopped IIS it wouldnt work.
Only way of achieving it is restarting the machine ..
I tried deleting the .pdb file from the debug directory, but explorer gave me a sharing violation. Since, I have stopped IIS .. i couldnt figure out which process was using the web service. Even closing / reopening the solution did not help.
So, can someone tell me what am i doing wrong ..
Thanks
Kannan
|
|
|
|
|
If you go to sysinternals.com, you can download HandleEx, this will tell you which process has hold of the file. MTS has the same problem..You have to CTRL-ALT-DELETE & kill the exe process to release the resource. The exe process of the web service (IIS).
Hope this helps..
Gerry.
|
|
|
|
|
I want to change the text that is displayed in the clock window. I've subclassed the windows and intercepted the WM_SETTEXT message, but the clock cotinues to run like normal, only the name of the windows changes (seen in Spy++). Can anyone help with this?
Greg J. Hedlund
SuperStar
|
|
|
|
|
If a phone number is dialed and a voice answers, how can my program recognize that it's a voice (and not a busy-signal or a modem signal)?
THANKS
|
|
|
|
|
I'm using DevStudio (old habits die hard ) to develop Java. An error message from Javac (displayed in the Output window) always has the format:
<fullFilespec>:<lineNumber>: <errorText>
For example:
D:\Foo\Foo.java:55: Unresolved symbol "foobar"
I'd like to be able to open the offending source file and have the cursor positioned at the start of the specified line, when I double click the error message. I understand I'd have to get the text of the line in the Output window, do some minimal parsing and invoke stock macros to open the file and position the cursor. Unfortunately, I'm DevStudio Macro disadvantaged (and generally pretty stupid).
Any help would be appreciated. Thx,
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
hi ravi,
I do not know macros .. but i know how to go about that in VC++
Actually there are lots of interfaces (a whole lot in VS.NET) available for manipulating the IDE/VStudio environment.
You need to have(query) the following interfaces,
IApplication, IDocument, ITextDocument, ITextSelection
You need to call the Open method of the IDocument interface with the "Text" Option.
It would be something like this,
if(pDocuments)
pDocuments->Open(CComBSTR(strFile), CComVariant("Text"),
CComVariant(VARIANT_FALSE), &p_Document)
For traversing inside the file, you need another interface called ITextDocument, Once you have the interface you can call,
if(pTxtDocuments)
pTxtDocuments->get_Selection(&m_pTxtSelection)
Before this you need initialize the Document context the Text you are going to refer.
Once you got the Text Document right for traversing inside you need to go for another interface called ITextSelection, and call a method inside that called GotoLine
if(pTxtSelection)
pTxtSelection->GoToLine(iLineNo,CComVariant(VARIANT_FALSE))
here FALSE would place the cursor in front of the line .. if you pass TRUE it would select that particular line.
Hope this helps
Cheers
Kannan
|
|
|
|
|
How can I read, write , and update information from a database like ACCESS.This may be long to answer but please do your best to at least give me a hint!
Thanks a lot!
|
|
|
|
|
Hi,
Here's a rather short answer. You can use ADO very easily to do this.
Check out CP for ADO tutorials.
|
|
|
|
|
I'm just starting with C++, and I'm trying to open a new DIALOG by pressing on a BUTTON on the first Dialog, can someone tell me how to do this??
|
|
|
|
|
CMyDialog::OnNewDlg()
{
CAnotherDlg anotherDlg;
anotherDlg.DoModal();
}
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
I have slight problem
Ive just made a small program, and I want to distribute it to all of my friends, the problem is it keeps saying on their machines that it needs dlls. They are the MFC**.dll s and im not sure what to do. I could send them all the dlls needed, but this would take ages. Is there anyway I can compile the dlls it requires into the program?
|
|
|
|
|
Go into the project settings, and on the first tab, you can select "Use MFC in a static library"
- Anders
|
|
|
|
|
thanks, but there is only one option and that is it "use MFC in shared DLL"
anyone know why?
|
|
|
|
|
Not all versions of VC have the option to statically link MFC. You can use the Dependency Viewer (in the MSVC program group, in the VC tools subgroup) to see which DLLs your program uses. It will, at the very least, be MFC42.DLL and MSVCRT.DLL, and maybe others depending on what classes you use.
--Mike--
http://home.inreach.com/mdunn/
The preferred snack of 4 out of 5 Lounge readers.
|
|
|
|
|
Hi
sure - in your project settings, step 3 of 4, just say that you want to statically link to the MFC library.
Kurt
|
|
|
|
|
Is there a way I could compile them within my exe without using the command in the properties of the project?
I have found the 3 dlls it uses, can I compile these indirectly into the program?
I found this in the MSDN cd:
The simplest and safest approach is to include the localized MFC resources in your application or DLL itself (or its satellite DLL if you are using one). This avoids the problems of installing MFC4xLOC.DLL properly. To do so, you follow the same instructions for the static case given above (setting the RC command line properly to point to the localized resources), except that you must also remove the /D_AFXDLL define that was added by AppWizard. When /D_AFXDLL is defined, AFXRES.H (and the other MFC RC files) don’t actually define any resources (because they will be pulled from the MFC DLLs instead).
(technical note 57)
Im not sure what it means though, could it be usefull to me?
thanks
tom
|
|
|
|
|
Why doesn't the following code work?
class abc {
public:
int var;
class xyz {
public:
void func() {
var = 10; // I can't access the variable!
}
};
};
Thanks!
Erik
|
|
|
|