Click here to Skip to main content
15,908,581 members
Home / Discussions / COM
   

COM

 
GeneralRe: problems with ATL/DCOM Pin
Renjith Ramachandran31-Dec-02 22:20
Renjith Ramachandran31-Dec-02 22:20 
QuestionRe: problems with ATL/DCOM Pin
Chen Jiadong13-Jun-07 20:47
Chen Jiadong13-Jun-07 20:47 
GeneralDCOM Server File Access Pin
Sasa Kajic24-Dec-02 14:00
Sasa Kajic24-Dec-02 14:00 
GeneralRe: DCOM Server File Access Pin
AlexO26-Dec-02 4:09
AlexO26-Dec-02 4:09 
GeneralPopup/Alertboxes in WebBrowser Control Pin
p_khasnis23-Dec-02 1:16
p_khasnis23-Dec-02 1:16 
GeneralNeed help using object in ATL ActiveX EXE window services server. Pin
bahruddina22-Dec-02 17:50
bahruddina22-Dec-02 17:50 
GeneralRe: Need help using object in ATL ActiveX EXE window services server. Pin
pba_23-Dec-02 12:41
pba_23-Dec-02 12:41 
GeneralRe: Need help using object in ATL ActiveX EXE window services server. Pin
bahruddina23-Dec-02 19:14
bahruddina23-Dec-02 19:14 
hi,

thanx for ur replay Smile | :)

I've change my code. But when I try to start my service I got an error :

Could not start the Test on Local Computer.
Error 1053: The service did not respond to the start or control request
in a timely fashion.

And one more thing; how i want to destroy the ATL object in a correct way:

m_Obj->Release()

or

m_Obj = NULL

Below is code for CServiceModule::Run() :

<small>void CServiceModule::Run()<br />
{<br />
    _Module.dwThreadID = GetCurrentThreadId();<br />
<br />
    HRESULT hr = CoInitialize(NULL);<br />
//  If you are running on NT 4.0 or higher you can use the following call<br />
//  instead to make the EXE free threaded.<br />
//  This means that calls come in on a random RPC thread<br />
//  HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);<br />
<br />
    _ASSERTE(SUCCEEDED(hr));<br />
<br />
    // This provides a NULL DACL which will allow access to everyone.<br />
    CSecurityDescriptor sd;<br />
    sd.InitializeFromThreadToken();<br />
    hr = CoInitializeSecurity(sd, -1, NULL, NULL,<br />
        RPC_C_AUTHN_LEVEL_PKT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);<br />
    _ASSERTE(SUCCEEDED(hr));<br />
<br />
    hr = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER, REGCLS_MULTIPLEUSE);<br />
    _ASSERTE(SUCCEEDED(hr));<br />
<br />
	<big>//<br />
	//create an ATL object<br />
	//<br />
	CComObject<CMyObj> *m_Obj;<br />
	CComObject<CMyObj>::CreateInstance(&m_Obj);</big><br />
<br />
	<big>//<br />
	//call object method<br />
	//<br />
	m_Obj->CallMe();</big><br />
<br />
    LogEvent(_T("Service started"));<br />
    if (m_bService)<br />
        SetServiceStatus(SERVICE_RUNNING);<br />
<br />
    MSG msg;<br />
    while (GetMessage(&msg, 0, 0, 0))<br />
        DispatchMessage(&msg);<br />
<br />
	<big>//<br />
	//free the object; I'm not sure wether to use m_Obj->Release() or m_Obj = NULL<br />
	//<br />
	m_Obj->Release();</big><br />
<br />
    _Module.RevokeClassObjects();<br />
<br />
    CoUninitialize();<br />
}</small>


Below is code for CMyObj :

<small>HRESULT CMyObj::FinalConstruct()<br />
{<br />
	return S_OK;<br />
}<br />
<br />
void CMyObj::FinalRelease()<br />
{<br />
		<br />
}<br />
<br />
<big>STDMETHODIMP CMyObj::CallMe()<br />
{<br />
	MessageBox(NULL, "Window services called me.", "MyObj", MB_OK);<br />
	return S_OK;<br />
}</big></small>


Sorry for the silly questions. Smile | :)
Thanx in advance.

Regards.
GeneralRe: Need help using object in ATL ActiveX EXE window services server. Pin
pba_24-Dec-02 4:28
pba_24-Dec-02 4:28 
GeneralRe: Need help using object in ATL ActiveX EXE window services server. Pin
geo_m30-Dec-02 5:56
geo_m30-Dec-02 5:56 
GeneralRe: Need help using object in ATL ActiveX EXE window services server. Pin
pba_30-Dec-02 6:03
pba_30-Dec-02 6:03 
GeneralRe: Need help using object in ATL ActiveX EXE window services server. Pin
bahruddina30-Dec-02 20:28
bahruddina30-Dec-02 20:28 
Questionpackaging a vc++ software? Pin
xxhimanshu21-Dec-02 1:40
xxhimanshu21-Dec-02 1:40 
AnswerRe: packaging a vc++ software? Pin
Renjith Ramachandran29-Dec-02 6:00
Renjith Ramachandran29-Dec-02 6:00 
GeneralATL COM thingie using inheritance Pin
Scracha20-Dec-02 4:56
Scracha20-Dec-02 4:56 
GeneralRe: ATL COM thingie using inheritance Pin
Ranjan Banerji20-Dec-02 5:44
Ranjan Banerji20-Dec-02 5:44 
GeneralRe: ATL COM thingie using inheritance Pin
pba_23-Dec-02 12:30
pba_23-Dec-02 12:30 
GeneralBeginners help with SAFEARRAY Pin
Obliterator19-Dec-02 8:24
Obliterator19-Dec-02 8:24 
GeneralRe: Beginners help with SAFEARRAY Pin
Barry Lapthorn19-Dec-02 20:47
protectorBarry Lapthorn19-Dec-02 20:47 
GeneralRe: Beginners help with SAFEARRAY Pin
work_to_live20-Dec-02 20:18
work_to_live20-Dec-02 20:18 
GeneralRe: Beginners help with SAFEARRAY Pin
Barry Lapthorn22-Dec-02 0:37
protectorBarry Lapthorn22-Dec-02 0:37 
GeneralRe: Beginners help with SAFEARRAY Pin
Barry Lapthorn23-Dec-02 3:16
protectorBarry Lapthorn23-Dec-02 3:16 
Generala COM+ design question Pin
Anonymous19-Dec-02 3:16
Anonymous19-Dec-02 3:16 
GeneralRe: a COM+ design question Pin
Burt Harris21-Dec-02 10:34
Burt Harris21-Dec-02 10:34 
QuestionGot CLSID/PROGID, how to access? Pin
Anonymous19-Dec-02 1:25
Anonymous19-Dec-02 1:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.