A guess: Run() on Win32 Service is generally executed on different thread. And CDatabase (may/may not) need MFC initialisation before its being invoked. And AfxWinInit is used to initialse MFC for non-MFC applications. Add the following line in the very begining of the Run() Method if (!AfxWinInit(::GetModuleHandle(NULL), NULL, NULL, 0)) { cerr << "MFC failed to initialize!" << endl; return 1; } and maybe an instance of CWinApp. Check AfxWinInit API in MSDN for more details. Hope this helps! Ram
Ramu Pulipati
Posts
-
Run Time Error When Using CDatabase -
Problem with the registryYou have to create RegKey using options 'REG_OPTION_NON_VOLATILE' instead of 'REG_OPTION_VOLATILE'. For more details, Check RegCreateKeyEx API in MSDN. If you are developing MFC/ATL based app...you can use CRegKey for easy registry access. Hope this helps. Ramu
-
HtmlViewIWebBrowser2 is protected member variable(m_pBrowserApp) of CHtmlView class. If you are using within CHtmlView derived class u can directly access 'm_pBrowserApp' or else you have to write a delegating function. Hth, Ramu
-
Overwriting COMCOM supports two kinds of object orientation over binary components with C++. They are Containment and Aggregation. Containment: This is traditional C++ wrapping up style where the new CoClass will implement the desired interface and internally use the Binary component to perform the operations. Aggregation: The new CoClass will delegate the implemented interafce requests to the binary component and any request to the CoClass from binary component will be delegated back. This is a kinda tricky thing and has got restrictions. Like, the component being aggregated should be an In-Proc Server and should support component aggregation. Advantage of Containment Over Aggregation: It doesnt have any restrictions. Advantage of Aggregation Over Containment: You dont have to implement all interface methods by youself in the component. You'll just delegate, this will be handy if interface has lot of methods. Check out COM books for further details. Thanks, Ramu
-
Any Idea why? ....What error message does it exactly give ??? Using '&' is not correct. Thanks, Ramu
-
About memory leaksVC++ debugger does not indicate the memory leaks. You can use CRT libary programatically to check the memory leaks, but this is of not great help compred to third party tools like BoundsChecker, etc. Thanks, Ramy
-
Getting shldisp.hif you didnt find from vs6, then download ms sdk... http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
-
Capturing the eventYou have to advise the button events (_CommandBarButtonEvents) from m_pButton and add event handlers to the sink map. Hth, Ramu
-
Any Idea why? ....JohnnyG wrote: memset(&RadarParityTable, 0, sizeof(RadarParityTable)); to memset(RadarParityTable, 0, sizeof(RadarParityTable)); Did you corrected this ??? Hth....;) Ramu
-
How to embed information data and retrieve it from other applicationsYes, you can do it. To be specific it should be ATL COM Dll which implemenets IDExtensibilty2 interface. This COM dll will be loaded when excel comes up. When user chooses to open the selected file, a notification will be fired by excel application to all the listners of IAppEvents. At this stage, component should read from file and stuff it in Excel columns. Check out more for COM add-in dlls in Office applications. Hth, Ramu
-
Help with Doc/View UsageRefer to Kb article http://support.microsoft.com/default.aspx?scid=kb;EN-US;q108587 to fetch the document or view class from anywhere in the MFC app. Once you have the document pointer, store the (dialog) data in member variable of document class. void CMyDialog::OnOK() { UpdateData(TRUE); CMyAppDoc * pDoc; pDoc = (((CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd))->MDIGetActive())->GetActiveDocument(); pDoc->m_Data = m_szDialogdata; pDoc->UpdateAllViews(NULL); } - UpdateAllViews inturn will call OnUpdate function internally. So, implement all the view presentation data on OnUpdate(). void CMyAppView::OnUpdate() { //load document using memeber variables //if using formview, call UpdateData(FALSE); } Hth, Ramu
-
terminate threadThere are couple of ways to terminate thread safely based on the problem here is the event approach, - CreateEvent() (named event to use across process'es) - CreateThread (or AfxBEginThread) and pass event as Thread Param - Keep listening to Event Signaling at application atomic times (WaitForSingleObject). - when Event is signaled or job is done, just return (use AfxEndThread() with AfxBeginThread() - MFC way) From main/any thread signal the event, when u want to stop the thread safely. To brutally kill the thread use: TerminateThread() Refer to samples in codeproject.com OR codeguru.com. Hth, Ramu
-
Single Instance Dialog BoxRegistering a dialog class is not suported(directly) in older versions of windows(9x and NT). Generally we use mutex with GUID for single instance. Check out the kb article: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q243953
-
Database ( table Update/Delete)Are you opening the RecordSet Connection over 'CRecordset::dynamic'???? Thanks, Ramu
-
Outlook Express data formatFYI, MSDN has articles abt Outlook Express format! Thanks, Ramu
-
Cryptic Error popupThis is MFC framework error message. This will be occur when you try to open a file which doesnt exist physically. If this problem occurs in InitInstance()..then manually populate the CCommandLineInfo Object. For more info, let us know what u r doing! Hth, Ramu
-
SAFEARRAY in VariantSTDMETHODIMPL MyCOMClass::VBMethod(VARIANT * vt) { SAFEARRAY *psa; if(vt == NULL) return E_POINTER; //assuming safearray consists BSTR. if not change to appropriate sa datatype if(vt->vt != VT_BSTR | VT_ARRAY) { return E_INVALIDARG; } psa = vt->parray; ATLASSERT(psa != NULL); //use safe array here return S_OK; } Hth, Ramu
-
How to deal with Ghost windows in XP System?I never did program for XP specific, still a guess. Are window styles (::GetWindowLong()) same for Ghost(Excutable Mode) & Non-Ghost(Debug Mode) ? If not, make them the similar styles. Use Spy++ to check the styles. Thanks, Ramu
-
How to keep my server aliveCouple of bluffs here...;) Go for 'Win32 Service' instead of 'LocalServer'. Will solve all the problems! Just to keep LocalServer running, Fool it! Set the event (hEventShutdown) manually when you want to close the app and dont set the it on CExeModule::Unlock(). I'm not sure this is the correct approach. Thanks, Ramu
-
Copying files/directoriesSHFileOperation() is the one you are looking for! It does have the progress window if you want to use. It does do copy recursive sub-directories. This does copy/rename/delete too...;) all in one package I dont think this is the fastest way but application level safest way as its a high level api. Thanks, Ramu