|
Interesting problem. One solution is to design an interface (GUI) for the service and have it communicate with the user.
Kuphryn
|
|
|
|
|
Can it not be done without a UI??
|
|
|
|
|
Create a seprate trayicon.exe application that can communicate with your service.
Todd Smith
|
|
|
|
|
Maybe I am wrong, but I remember than when I some time ago did something with event log, I have first register a message before use the eventlog - the message format was something like
messageID=XYZ; "Some error occured in function %s"
This message definition is stored somewhere in registry I guess...
Then when I wanted to write such an error to eventlog I only refer to the definition and add the string to be completed (say "main").
ReportError( XYZ; "main" );
in eventlog viewer it appears to be:
"Some error occured in function main"
I think that this is because it can save a quite big amount of space in the evt file, because they can store only the "main" string in each entry instead of the whole message.
I don't think, that this will help you a much, but at least you know reason why it doesn't work for you now.
|
|
|
|
|
What is the error? What flags do you use for FormatMessage? Is it possible that not all the messages came from the same message DLL? How do you deal with parameters?
|
|
|
|
|
I am implementing interface to handle event . I am stuck in defining _ATL_FUNC_INFO .
Sample of my code is
/////////////////////////////////////////////////////////////////////////////
class CCTIHPPCHelper;
#define EVENT_SOURCE_CTI 1
#define CTIHPPCEventDIID HiPathProCenterLibrary:IID__IMediaManagerEvents
typedef IDispEventSimpleImpl<event_source_cti, cctihppchelper,="" &ctihppceventdiid=""> SCTIHPPCEventImpl;
and in .tlh file i have
_IMediaManagerEvents : IDispatch
{
//
// Wrapper methods for error-handling
//
// Methods:
HRESULT EventOccurred (
struct IMediaEvent * MediaEvent );
};
My problem is how should i define _ATL_FUNC_INFO as parameter in "EventOccurred" is a struct type and what should be my BEGIN_SINK_MAP definition.
Is there any other way for implementing interface.
Thanks
|
|
|
|
|
Hi,
I didn't get your question completelly, but the general approach how to handle the events is very simple in ATL.
Assume you have class CWantEvents and you want to receive the event you described.
Then you have to define the sink map as follows:
<br />
BEGIN_SINK_MAP(CWantEvents)<br />
SINK_ENTRY_EX(0, __uuidof(_IMediaManagerEvents), 1, OnEventOccurred)<br />
END_SINK_MAP()<br />
<br />
void __stdcall OnEventOccurred( IMediaEvent* ipMediaEvent )<br />
{<br />
};<br />
Then when you attach to the event source (using DispEventAdvise ), you have to be able to receive such an event.
Hope this helps.
Ya, and note - the member marked in my sample as dispid might be different for you (depend on dispID of the real event method you want to receive)
|
|
|
|
|
Ok, if I got this right, event sinking is when you listen for COM events?
I am trying to listen for Internet Explorer events (idc_print, idc_printpreview) from an ActiveX control within internet explorer. I was wondering if someone can help me out or point me in the right direction.
MoMad the NoMad
|
|
|
|
|
idc_print? idc_printpreview? Take a look at the DWebBrowserEvents2 dispinterface. Those are the events you can sink. (At least what's been published by Microsoft. )
--
tlhIngan maH! Heghlu'meH QaQ jajvam!
|
|
|
|
|
In ATL6 (VS6) creating an interface like this
interface ICtrl1 : IDispatch<br />
{<br />
typedef enum {Diedel, Doedel, Doing} DUMMY;<br />
[id(1), helpstring("method Foo")] HRESULT Foo([in]DUMMY Dummy);<br />
};
in Foo.idl the file was properly compiled by MIDL.
However doing the same in ATL7 in the controls headerfile
__interface ICtrl1 : public IDispatch<br />
{<br />
typedef enum {Diedel, Doedel, Doing} DUMMY;<br />
[id(1), helpstring("method Foo")] HRESULT Foo([in] DUMMY Dummy);<br />
};
results in an error MIDL2025 : syntax error : expecting a type specification near "DUMMY".
I have no idea what I am doing wrong here
Rainer
|
|
|
|
|
I am little bit rusty in IDL, but I do not think enum inside of interface is valid syntax (granted that VC6 compiled that). Compile in VC6, use OleView on the resulting tlb, my guess is that older MIDL just silently moved that typedef out of interface definition during compilation.
|
|
|
|
|
|
Use stream manipulators. See this[^].
Pavel
Sonork 100.15206
|
|
|
|
|
Hi,
i am new to ATL.i want to send a simple mail with an attachment using the ATL DLL.Can anyone help me out of this problem?If possible pls paste the code/syntax.
Thanks for all in advance
|
|
|
|
|
Your going to need a library that supports SMTP, or implement your own version from the RFC. There are a few libs on this site, but you need to make sure that they don't make use of MFC, unless your happy to link to MFC in your ATL projects, but it will bloat them.
Here is an Win API version, but its very basic
http://www.codeproject.com/internet/zsmtp.asp[^]
This next article has a very good implementation that I can vouch for, but says its MFC based. On the whole its not, it just makes use of CString, which is now avaliable in ATL without binding to MFC. PJ points out that it does not use the MFC socket classes as they are message loop based which is no good if you need to write an NT service.
http://www.codeproject.com/internet/csmtpconn.asp[^]
Quote from a clever bloke :
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein
|
|
|
|
|
ATL7 have support for SMTP out of the box
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi, everyone!
Please look at the following codes. I think I overload the
operator clearly. But compiler still say that it is ambiguous.
Here are the source codes and related error message.
Source:
--------
#include <iostream>
#include <map>
#include <set>
#include <string>
using namespace std;
class employee_data {
public:
employee_data() : name (""), skill(0), salary(0) {}
employee_data(string n, int s, long sa) :
name (n), skill (s), salary (sa) {}
string name;
int skill;
long salary;
friend ostream& operator<< (ostream& os, const employee_data& e);
};
ostream& operator<< (ostream& os, const employee_data& e) {
os << "employee: " << e.name << " " << e.skill << " " << e.salary;
return os;
}
class employee {
public:
employee (int i, employee_data e) :
identification_code (i), description (e) {}
int identification_code; // key expression to identify an employee
employee_data description;
bool operator< (const employee& e) const {
return identification_code < e.identification_code; }
};
int main()
{
set <employee, less<employee> > employee_set;
multiset <employee, less<employee> > employee_multiset;
map <int, employee_data, less<int> > employee_map;
multimap <int, employee_data, less<int> > employee_multimap;
employee_data ed1 ("john", 1, 5000);
employee_data ed2 ("tom", 5, 2000);
employee_data ed3 ("mary", 2, 3000);
employee e1 (1010, ed1);
employee e2 (2020, ed2);
employee e3 (3030, ed3);
pair<const int, employee_data> a[2] = { make_pair (2020, ed2),
make_pair (3030, ed3) };
employee_map.insert (&a[0], &a[2]);
employee_data d = employee_map[2020];
cout << d << endl;
return 1;
}
--------
Error message:
--------
C:\Program Files\Microsoft Visual Studio\MyProjects\testMap1\testMap1.cpp(86) : error C2593: 'operator <<' is ambiguous
--------
Thanks in advance,
George
|
|
|
|
|
Hi, everyone!
I have tried it in VC7.0 and Linux gcc. Both OK, something
wrong with VC6.0?
George
|
|
|
|
|
Templates with VC6 sort of stink. :/
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Thanks, Tim buddie!
George
|
|
|
|
|
It works OK in VC++6.0 sp5. Maybe you should consider installing that service pack.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, Joaquín buddie!
I have installed VC7.0. I think I should give up
poor VC6.0.
Have a nice weekend,
George
|
|
|
|
|
I want my ATL component to expose a function that can accept string as an argument. What i am doing is:
STDMETHODIMP CProduction::SetCountry(BSTR name)
{
MesageBox(NULL, reinterpret_cast<char *>name, "Country" , MB_OK);
return S_OK;
}
i.e i accept string as BSTR in argument and display it in message box.
Similarly from the client side i am calling this function as
myobject.SetCountry("Indonesia");
The problem is that this is not working correctly. Both client and server program runs successfully. But the string is not correctly passed in the ATL exposed function. The MessageBox only show one character i.e "I"
Can any one tell me what is the problem and how can i acceept string in ATL exposed function. Currently i am using
[in] BSTR name.
Is this correct ?
|
|
|
|
|
That is correct, but to use it correctly you'll need to convert it, unless you're making a UNICODE build.
Check out the W2T macro;
{
USES_CONVERSION;
MessageBox(NULL,W2T(name),"Country",MB_OK);
}
will do what you want.
Steve S
[This signature space available for rent]
|
|
|
|
|
Hi, everyone!
Please look at the following source codes, I compile them
in VC6.0. I have tried map.insert(make_pair(...)) works OK.
But map.insert(interator, interator) is not working perperly.
How to resolve the trouble?
--------
#include <iostream>
#include <map>
#include <set>
#include <string>
using namespace std;
class employee_data {
public:
employee_data() : name (""), skill(0), salary(0) {}
employee_data(string n, int s, long sa) :
name (n), skill (s), salary (sa) {}
string name;
int skill;
long salary;
friend ostream& operator<< (ostream& os, const employee_data& e);
};
ostream& operator<< (ostream& os, const employee_data& e) {
os << "employee: " << e.name << " " << e.skill << " " << e.salary;
return os;
}
class employee {
public:
employee (int i, employee_data e) :
identification_code (i), description (e) {}
int identification_code; // key expression to identify an employee
employee_data description;
bool operator< (const employee& e) const {
return identification_code < e.identification_code; }
};
int main()
{
map <int, employee_data, less<int> > employee_map;
employee_data ed1 ("john", 1, 5000);
employee_data ed2 ("tom", 5, 2000);
employee_data ed3 ("mary", 2, 3000);
employee e1 (1010, ed1);
employee e2 (2020, ed2);
employee e3 (3030, ed3);
pair<int, employee_data> a[2] = { make_pair (2020, ed2),
make_pair (3030, ed3) };
employee_map.insert (&a[0], &a[2]);
return 1;
}
--------
Errors:
--------
C:\Program Files\Microsoft Visual Studio\MyProjects\testMap1\testMap1.cpp(75) : error C2664: 'class std::_Tree<int,struct
std::pair<int const ,class employee_data>,struct std::map<int,class employee_data,struct std::less<int>,class
std::allocator<cl
ass employee_data> >::_Kfn,struct std::less<int>,class std::allocator<class employee_data> >::iterator __thiscall
std::map<int,class employee_data,struct std::less<int>,class std::allocator<class employee_data> >::insert(class
std::_Tree<int,struct
std::pair<int const ,class employee_data>,struct std::map<int,class employee_data,struct std::less<int>,class
std::allocator<class employee_data> >::_Kfn,struct std::less<int>,class std::allocator<class employee_data> >::iterator,const
struct std::p
air<int const ,class employee_data> &)' : cannot convert parameter 1 from 'struct std::pair<int,class employee_data> *' to
'class std::_Tree<int,struct std::pair<int const ,class employee_data>,struct std::map<int,class employee_data,struct
std::les
s<int>,class std::allocator<class employee_data> >::_Kfn,struct std::less<int>,class std::allocator<class employee_data>
>::iterator'
No constructor could take the source type, or constructor overload resolution was ambiguous
--------
Thanks in advance,
George
|
|
|
|
|