|
Hi Mckay,
Whenever I try making a new instance of the class i get this error:
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!
Program: ...
File: c:\program files\microsoft visual studio 8\vc\atlmfc\include\atlbase.h
Line: 2706
Expression: _pAtlModule == 0
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
---------------------------
Abort Retry Ignore
---------------------------
at:
class ATL_NO_VTABLE CAtlModule : public _ATL_MODULE
{
public :
static GUID m_libid;
IGlobalInterfaceTable* m_pGIT;
CAtlModule() throw()
{
ATLASSERT(_pAtlModule == NULL);
Is there a way to counter this or solve this?
Thanks,
Jayjay
|
|
|
|
|
Hello,
This is with reference to an article at http://www.developer.com/net/cplus/article.php/3624581 about Programming the Windows Vista Event Log.
We build and run the application as per information found in this article. And getting the Operational and Debug events.
Thats great.
Now, we have made some changes and getting some wrong output.
I request you to have quick look on the following stuff and let us know where we are wrong.
We have made some changes in the code as follows –
The manifest.h file contains –
#pragma once
EXTERN_C __declspec(selectany) const GUID MYCOMPANY_HPFS_PUBLISHER = {0x9cde86c9, 0xdfb9, 0x463f, {0xb2, 0xc5,0x71,0xee,0xc2,0x32,0xa6,0x9c}};
#define MYCOMPANYOP 0x10
#define MYCOMPANYDEBUG 0x0
EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR DNP_OP_EVENT = {0x1, 0x0, 0x10, 0x4, 0x0, 0x0, 0x8000000000000000};
#define DNP_OP_EVENT_value 0x1
EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR DNP_DEBUG_EVENT = {0x2, 0x0, 0x0, 0x4, 0x0, 0x0, 0x4000000000000000};
#define DNP_DEBUG_EVENT_value 0x2
#define MSG_SimpleMessage 0xB0000001L
Here, we have just renamed #define values.
Also, we have made some changes in EventLogging.Cpp as follows –
// EventLogging.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <evntprov.h>
#include <winevt.h>
#include "Manifest\manifest.h"
# pragma comment (lib, "wevtapi.lib")
int _tmain(int argc, _TCHAR* argv[])
{
REGHANDLE hPub = NULL;
ULONG res = EventRegister(&MYCOMPANY_HPFS_PUBLISHER, NULL, NULL, &hPub);
if (ERROR_SUCCESS == res){
_tprintf(_T("Event registered successfully\n"));
}
else{
_tprintf(_T("Could not register event\n"));
}
EVENT_DATA_DESCRIPTOR opEventDesc;
PWSTR pwsOp = L"HPFS : My Operational Event";
EventDataDescCreate(&opEventDesc, pwsOp, ((ULONG)wcslen(pwsOp)+1)*sizeof(WCHAR));
res = EventWrite(hPub, &DNP_OP_EVENT, 1, &opEventDesc);
if (ERROR_SUCCESS == res){
_tprintf(_T("Operational event successfully raised\n"));
}
else{
_tprintf(_T("Could not raise operational event Error = %i\n"), res);
}
EVENT_DATA_DESCRIPTOR debugEventDesc;
PWSTR pwsDebug = L"HPFS : My Debug Event";
EventDataDescCreate(&debugEventDesc, pwsDebug, ((ULONG)wcslen(pwsDebug)+1)*sizeof(WCHAR));
res = EventWrite(hPub, &DNP_DEBUG_EVENT, 1, &debugEventDesc);
if (ERROR_SUCCESS == res){
_tprintf(_T("Debug event successfully raised\n"));
}
else{
_tprintf(_T("Could not raise debug event. Error = %i\n"), res);
}
EventUnregister(hPub);
return 0;
}
Also we have made some changes to manifest.xml file as follows –
<!--Publisher Info -->
<provider name="MYCOMPANY-HPFS"
guid="{9CDE86C9-DFB9-463f-B2C5-71EEC232A69C}"
symbol="MYCOMPANY-HPFS_PUBLISHER"
resourceFileName="C:\Work_Shashi\EventLoggingCode\Debug\EventLogging.exe" messageFileName="C:\Work_Shashi\EventLoggingCode\Debug\EventLogging.exe">
<!--Channel to which this Publisher can publish -->
<channels>
<channel chid="MyOpChannel"
name="MYCOMPANY-HPFS/Operational"
type="Operational"
symbol="MYCOMPANYOP"
isolation="Application" enabled="true"/>
<channel chid="MyDebugChannel"
name="MYCOMPANY-HPFS/Debug"
type="Debug"
symbol="MYCOMPANYDEBUG"
isolation="Application" enabled="true"/>
</channels>
Where "C:\Work_Shashi\EventLoggingCode\Debug\EventLogging.exe" this is my .exe address.
Now, we are getting Debug events properly. But, we are not able to get Operational events. We can see “Operational” tab but no event added in that.
Actually, our intention is to create a tab structure in Event viewer “Applications and Services Logs > MYCOMPANY > HPFS > Operational” and read and write operational events.
Kindly let us know what is the problem in our code.
Thank you.
With regards,
Shashikant
|
|
|
|
|
I need load two DLL, a.dll and b.dll.
In a.dll has fun() function and b.dll has fun() too.
How to distinguish between a.dll/fun() and b.dll/fun().
|
|
|
|
|
|
hanlei0000000009 wrote: In a.dll has fun() function and b.dll has fun() too.
How to distinguish between a.dll/fun() and b.dll/fun().
Using GetProcAddress and a typedef (with different names) for prototyping the function should help.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
I need to display icons in my TreeCtrl , icon image should change depending on the tree node type.
If it is Root node I need to display one icon. And for branches which is having child items I need to dispay different icon. For child items with no roots I need to display separate icon.
How do I know the nodes which are having child items ?
Presently iam able to show only one icon to all nodes.
m_lstImages.Create( 16, 16, ILC_COLOR, iconCount, 1 );
for( int i = 0; i < iconCount; i++ )
{
HICON hIcon;
hIcon = AfxGetApp()->LoadIcon( IDI_ICON1 + i );
m_lstImages.Add( hIcon );
}
GetTreeCtrl().SetImageList( &m_lstImages, TVSIL_NORMAL );
|
|
|
|
|
Preethi_123 wrote: How do I know the nodes which are having child items ?
Use CTreeCtrl::ItemHasChildren
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Hi all,
This is my constructor:
CUpdateServiceModule::CUpdateServiceModule()
{
m_status.dwControlsAccepted |= SERVICE_ACCEPT_PAUSE_CONTINUE;
m_bIsRunning = FALSE;
m_bIsPaused = FALSE;
MessageBox(NULL, L"Contructor",NULL, NULL);
}
I am wondering why the message box constructor appears when ever I rebuild my project, install the project and uninstall the project. Can anyone tell me why is that or what information do you guys need to know that?
Thanks,
jayjay
|
|
|
|
|
because the constructor function of CUpdateServiceModule() will be called by the com register.
【成功就是在跌倒之后还能爬起来...】
|
|
|
|
|
even during uninstall and building?
|
|
|
|
|
When building your project, VC will register the component at the end of the compilation, thus the message box is shown.
And I guess an instance of that class is created when the component is unregistered (during an uninstall).
|
|
|
|
|
|
register and unregserver message during uninstall and building.
【成功就是在跌倒之后还能爬起来...】
|
|
|
|
|
monsieur_jj wrote:
CUpdateServiceModule::CUpdateServiceModule()
{
m_status.dwControlsAccepted |= SERVICE_ACCEPT_PAUSE_CONTINUE;
m_bIsRunning = FALSE;
m_bIsPaused = FALSE;
MessageBox(NULL, L"Contructor",NULL, NULL);
}
Be careful with the m_status.dwControlsAccepted .
The way the statement is written it will most likely contain garbage data when you build for release, unless it's initialized in some base class of CUpdateServiceModule .
Consider changing to
m_status.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE;
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
I get similiar other warnings such as
warning C4996: 'strcat' was declared deprecated
warning C4996: 'fopen' was declared deprecated
warning C4996: 'itoa' was declared deprecated
why and when do these warnings arise ?
How to overcome them?
- thanks..
|
|
|
|
|
kapardhi wrote: why and when do these warnings arise ?
Because Microsoft introduced more secure versions of these functions. So either follow the advice given in the warning message (use the more secure version, like strcat_s) or disable the warning 4996 (you can specify that in the project options).
|
|
|
|
|
* You may suppress all the compiler warnings using /w option.
or
* Use /wd to supress a specific warning. Eg. /wd4996 will disable the compiler warning with ID 4996.
Regards,
Rane
|
|
|
|
|
I am using Visual c++ 6.0 MFC,
I have a problem to print pay slip on Dot Matrix printer. So I need to write my data on Text File and after Printing it.
Clearly, How can I Write to Text File et Print this File After with Visual c
++ 6.0 MFC.
Thanks
|
|
|
|
|
You can play with files in MFC using CFile class. Below shown code snippet will be of little help:
CFile cf_object;
cf_object.Open( "c:\\CP\\CP_test.txt", CFile::modeCreate|CFile::modeWrite);
char szText[100];
strcpy(szText, "File Write Test");
cf_object.Write (szText,100);
Regards,
Rane
|
|
|
|
|
|
These guys are fast. Let me add up something that has not been said yet:
You can open the port to which the printer is attached (usually LPT1) as a file (just pass LPT1 as the file name to the function which opens or creates the file). You can then just write text to this opened file, and you'll see the printer is printing it out. If you consult with the printer documentation, it must have some specific ASCII command patterns (known as EPSON ESC CODE sequences), which you could follow to get formatted output, such as a receipt.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Hi All
I want to convert MDI application code to dailog application code.Can any one help me which class i need to write in dailog application..
Or can i show MDI Out put on dailog application in list box?
Example link in here http://www.codeguru.com/cpp/w-p/clipboard/externallinks/article.php/c9155/[^]">
Plz help me..
modified on Monday, September 1, 2008 2:03 AM
|
|
|
|
|
What does the link have to do with your question ?
Anyway, there's no easy way to convert a MDI application to dialog based application. You need to restart a new project and copy/paste the classes and code you need. Of course, this is probably more complicated than that because the structure of the project changes completely.
|
|
|
|
|
Ok Can i show MDI out put on Dailog Application?
|
|
|
|
|
What do you mean ? If you want to put your MDI app contained on your dialog, that's not possible. Think a bit about it: you can have multiple documents open at the same time, how would do you put that on one single dialog ?
No, the best way to go is to completely rewrite your application and reuse part of the code. Otherwise this will be a complete mess.
|
|
|
|
|