|
|
You are fast you changed your reply to a link!
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
|
i mean how can i give a name to my module that can be referenced to check that call to a specific function has come from which module.
|
|
|
|
|
See GetModuleBaseName .
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
On Visual Studio you may specify the name of the executable (if I understand your request). For instance (on VS2005 , at least)
Choose menu Project->Properties and then, select (on the appeared window) the Configuration Properties->Linker node and finally set the Output File property with the intended name.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
this is wat i exactly wanted but there is no output file property in linker options.m using vs2005.
|
|
|
|
|
Yes, there is. If you select the Configuration properties->Linker node (don't select any of the child nodes), then you may find the Output File property as the first item of the listview (such listview is on the right of the window).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
yeah thanx...it is in Configuration properties->C/C++.
|
|
|
|
|
I'm not sure whether this is the right place to ask. I am having difficulty trying to handle, in a conventional (unmanaged code) C++ application, an event raised by a managed code component.
I am tackling this as a C++ problem because I can successfully handle the same event, from the same component, in a VB6 application.
The component raising the event is implemented in C# and enclosed in a COM wrapper. On the C# side we have the following code:
public interface IMyObjectEvents
{ [DispId(1)] void TakenFocus(); }
public class MyObjectInterface : IMyObject
{
public event TakenFocusDelegate TakenFocus;
public void FireTakenFocus()
{
if (TakenFocus != null) TakenFocus();
}
}
The following code in an unmanaged VB6 application works fine:
Dim WithEvents oMyControl As MyControl.MyObjectInterface
Private Sub oMyControl_TakenFocus()
MsgBox "Event caught"
End Sub
When the object calls FireTakenFocus(), I see the messagebox "Event caught"
In C++ it all gets a bit harder. My code is in an MFC dll. I created a new class CEventSink as follows:
In the header file:
class CEventSink : public CCmdTarget
{
DECLARE_DYNCREATE(CEventSink)
CEventSink(); // protected constructor used by dynamic creation
// Attributes
public:
// Operations
public:
void Connect(LPUNKNOWN lpuEventSource);
void Disconnect();
void OnTakenFocus();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CEventSink)
public:
virtual void OnFinalRelease();
//}}AFX_VIRTUAL
// Implementation
protected:
virtual ~CEventSink();
// Generated message map functions
//{{AFX_MSG(CEventSink)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
// Generated OLE dispatch map functions
//{{AFX_DISPATCH(CEventSink)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_DISPATCH
DECLARE_DISPATCH_MAP()
DECLARE_INTERFACE_MAP()
private:
DWORD m_dwEventSinkHandle;
LPUNKNOWN m_puEventSource;
};
Then the implementation in the cpp file:
IMPLEMENT_DYNCREATE(CEventSink, CCmdTarget)
CEventSink::CEventSink()
{
EnableAutomation();
m_puEventSource = NULL;
}
CEventSink::~CEventSink()
{
Disconnect();
}
void CEventSink::OnFinalRelease()
{
CCmdTarget::OnFinalRelease();
}
BEGIN_MESSAGE_MAP(CEventSink, CCmdTarget)
//{{AFX_MSG_MAP(CEventSink)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BEGIN_DISPATCH_MAP(CEventSink, CCmdTarget)
//{{AFX_DISPATCH_MAP(CEventSink)
DISP_FUNCTION_ID(CEventSink, "TakenFocus", 1, OnTakenFocus, VT_EMPTY, VTS_NONE)
//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()
// {B0FD7D1F-6686-44B3-A040-A2BF4E37DA30}
static const IID IID_IEventSink =
{ 0xb0fd7d1f, 0x6686, 0x44b3, { 0xa0, 0x40, 0xa2, 0xbf, 0x4e, 0x37, 0xda, 0x30 } };
// {0C4298D9-7CEC-46D6-A865-79204E29557D}
static const IID IID_IMyObjectEvents =
{ 0x0c4298d9, 0x7cec, 0x46d6, { 0xA8, 0x65, 0x79, 0x20, 0x4e, 0x29, 0x55, 0x7D } };
BEGIN_INTERFACE_MAP(CEventSink, CCmdTarget)
INTERFACE_PART(CEventSink, IID_IMyObjectEvents Dispatch)
END_INTERFACE_MAP()
void CEventSink::Connect(LPUNKNOWN lpuEventSource)
{
AfxConnectionAdvise(m_puEventSource = lpuEventSource, IID_IMyObjectEvents,
GetIDispatch(FALSE), FALSE, &m_dwEventSinkHandle);
}
void CEventSink::Disconnect()
{
if (m_puEventSource != NULL)
{
AfxConnectionUnadvise(m_puEventSource, IID_IMyObjectEvents,
GetIDispatch(FALSE), FALSE, m_dwEventSinkHandle);
m_puEventSource = NULL;
}
}
void CEventSink::OnTakenFocus()
{
Trace("Event caught");
}
In my startup code I create an instance of the C# object and of the event sink, and call Connect (error checking code omitted for brevity):
IMyObjectPtr oMyObject;
oMyObject.CreateInstance(clsidMyObjectInterface);
CRuntimeClass *prtcEventSink = RUNTIME_CLASS(CEventSink);
CEventSink *pSink = (CEventSink *)prtcEventSink->CreateObject();
LPUNKNOWN pUnk;
oMyObject.QueryInterface(IID_IUNKNOWN, &pUnk);
pSink->Connect(pUnknown);
The connect works fine but as soon as my C# component calls FireTakenFocus I get a .net runtime error message:
Member not found. Exception from HRESULT 0x8002003
[DISPID_E_MEMBERNOTFOUND]
(detail)
ForwardCallToInvokeMember(String MemberName, BindingFlags Flags, Object Target,
Int32[] aWrapperTypes, MessageData &msgData)
CEventSink::OnTakenFocus is never called.
Any suggestions where I'm going wrong? As I said, I'm sure the problem is on the C++ side of the fence because a VB6 app can field the event without batting an eyelid.
Keith
|
|
|
|
|
Progress, of a sort...
I changed the code to pass the IDispatch interface pointer, rather than IUnknown, into the connect call. Ie. instead of:
LPUNKNOWN pUnk;
oMyObject.QueryInterface(IID_IUNKNOWN, &pUnk);
pSink->Connect(pUnknown);
I now have:
LPDISPATCH pDispatch = Sink->GetIDispatch(FALSE);
pSink->Connect(pDispatch);
Now it no longer breaks - but it doesn't catch the event either. A break point on the first line of OnTakenFocus() is never hit.
Any ideas yet?
|
|
|
|
|
How can I hide a process form being displayed in task manager? using win32 or C++...
|
|
|
|
|
Will you please stop spamming the site every day with your stupid posts?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
if u have interest u can help ..other wise ..plz shut u r mouth..and .........
|
|
|
|
|
|
tns_ranjith wrote: if u have interest u can help ..other wise ..plz shut u r mouth..and .........
You've been asking "How to hide my process from task manager" for weeks, refused to answer the question "Why do you want to hide it", and you ignored all polite replies saying that we WON'T help write malware.
Now you think that you can ask me to shut up? You ignorant little fool. I have an answer for your query: SOD OFF!
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
tns_ranjith wrote: if u have interest u can help ..other wise ..plz shut u r mouth..and .........
Well well, this will really help you receive help from people here
|
|
|
|
|
and what possible justification could you have for doing a thing like that ?
We dont spend our time helping people write trojans, virii or such
'g'
|
|
|
|
|
gudda musukoni work chesukora ..picchi nako..
|
|
|
|
|
tns_ranjith wrote: gudda musukoni work chesukora ..picchi nako..
Im sorry, I dont understand. Since you appear to be swearing at me, Ive report your entire post as abuse and it will hopefully soon be removed. If you continue to treat people here like this, I'll also recommend your account be deleted - capiche ?
|
|
|
|
|
i dont think you have to be sorry.. he was actually swearing. and i dont think you would want to know the meaning.
|
|
|
|
|
gudda musukoni work chesukora ..picchi nako..
Translation:
"Sorry Sir, I'm a drooling idiot.. I will work hard and post better questions in the future"
|
|
|
|
|
Thanks - I needed that laugh
|
|
|
|
|
I think that 'Fleet Admiral ' is the solution. Please let me know if I won the prize.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi All
how to solve this Debug.
unhandled exception at 0x00541ccf in Test.exe:0xC0000005;Access vilolation reading location 0xfeeefeee
Plz help me
|
|
|
|