Click here to Skip to main content
15,922,407 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: stl sorting question Pin
Warren Stevens24-Feb-06 11:45
Warren Stevens24-Feb-06 11:45 
Questionstl string parsing for DB query statement Pin
xcavin23-Feb-06 5:48
xcavin23-Feb-06 5:48 
AnswerRe: stl string parsing for DB query statement Pin
Roland Pibinger24-Feb-06 23:23
Roland Pibinger24-Feb-06 23:23 
QuestionError In Building simple ATL application Pin
maharaja pandian23-Feb-06 1:47
maharaja pandian23-Feb-06 1:47 
AnswerRe: Error In Building simple ATL application Pin
Stephen Hewitt24-Feb-06 22:40
Stephen Hewitt24-Feb-06 22:40 
QuestionUsing ShellContextMenu in my application Pin
empit4ever22-Feb-06 11:18
empit4ever22-Feb-06 11:18 
QuestionAccess to COM methods inside Windows Service ATL Pin
cmacgowan22-Feb-06 6:01
cmacgowan22-Feb-06 6:01 
AnswerRe: Access to COM methods inside Windows Service ATL Pin
cmacgowan24-Feb-06 8:28
cmacgowan24-Feb-06 8:28 
Hi ...

The solution to this problem is to put the com call to ITest above the message loop. Below is the corrected code.

Thanks,
Chris

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 />
    LogEvent(_T("Blue Service started"));<br />
    LogEvent(_T("Message 1"));<br />
    LogEvent(_T("Message 2"));<br />
<br />
    if (m_bService)<br />
        SetServiceStatus(SERVICE_RUNNING);<br />
<br />
<br />
    // --------------------------------------------<br />
    // We will try to call the COM Object from here <br />
<br />
	char progID[] = "Blue.Test.1";<br />
<br />
    string strTemp; <br />
    char szTemp[10]; <br />
<br />
	// Now make that object.<br />
	CLSID clsid;<br />
	wchar_t wide[80]; <br />
	mbstowcs(wide, progID, 80);<br />
	CLSIDFromProgID(wide, &clsid);<br />
<br />
    LogEvent(_T("Attempt to create the ITest Com Object"));<br />
<br />
	ITest* pTest = NULL;<br />
<br />
    hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_ITest, (void**)&pTest); <br />
<br />
	if(SUCCEEDED(hr))<br />
	{<br />
		pTest->TestBeep(); <br />
	}<br />
    else<br />
    { <br />
        // LogEvent(_T("Error: ITest failed hresult"));<br />
        sprintf(szTemp, "%h", hr); <br />
        strTemp = "Error: ITest failed.  HResult=" + (string)szTemp; <br />
        LogEvent(_T(strTemp.c_str()));<br />
    } <br />
<br />
<br />
    MSG msg;<br />
    while (GetMessage(&msg, 0, 0, 0))<br />
        DispatchMessage(&msg);<br />
<br />
    _Module.RevokeClassObjects();<br />
<br />
<br />
    CoUninitialize();<br />
}<br />
<br />

QuestionActiveX classname chnage Pin
Anilkumar K V20-Feb-06 16:42
Anilkumar K V20-Feb-06 16:42 
Questioni write a general dll want only use ATL's some windows class, how to do? Pin
HOW WHAT18-Feb-06 20:01
HOW WHAT18-Feb-06 20:01 
AnswerRe: i write a general dll want only use ATL's some windows class, how to do? Pin
georgeraafat20-Feb-06 9:07
georgeraafat20-Feb-06 9:07 
GeneralRe: i write a general dll want only use ATL's some windows class, how to do? Pin
HOW WHAT20-Feb-06 20:48
HOW WHAT20-Feb-06 20:48 
GeneralRe: i write a general dll want only use ATL's some windows class, how to do? Pin
Stephen Hewitt21-Feb-06 19:28
Stephen Hewitt21-Feb-06 19:28 
Questionin WTL, can these code not use in WinMain? Pin
HOW WHAT18-Feb-06 19:58
HOW WHAT18-Feb-06 19:58 
AnswerRe: in WTL, can these code not use in WinMain? Pin
Douglas Troy20-Feb-06 7:16
Douglas Troy20-Feb-06 7:16 
Questionproblem with ocx... Pin
padma_0117-Feb-06 1:07
padma_0117-Feb-06 1:07 
GeneralRe: problem with ocx... Pin
Joonsong Jang17-Feb-06 19:59
Joonsong Jang17-Feb-06 19:59 
QuestionAdd a New ATL Object Pin
Anil_vvs15-Feb-06 18:42
Anil_vvs15-Feb-06 18:42 
AnswerRe: Add a New ATL Object Pin
Stephen Hewitt16-Feb-06 11:45
Stephen Hewitt16-Feb-06 11:45 
QuestionActiveX ATL control Pin
Anilkumar K V13-Feb-06 18:43
Anilkumar K V13-Feb-06 18:43 
GeneralRe: ActiveX ATL control Pin
Joonsong Jang17-Feb-06 19:36
Joonsong Jang17-Feb-06 19:36 
QuestionIcons not dragging in listctrl Pin
Parampreet Sidhu13-Feb-06 5:13
Parampreet Sidhu13-Feb-06 5:13 
AnswerRe: Icons not dragging in listctrl Pin
Parampreet Sidhu14-Feb-06 0:25
Parampreet Sidhu14-Feb-06 0:25 
QuestionHow to determine if an ActiveX control is signed or not Pin
KKTECH12-Feb-06 23:03
KKTECH12-Feb-06 23:03 
AnswerRe: How to determine if an ActiveX control is signed or not Pin
Michael Dunn13-Feb-06 7:44
sitebuilderMichael Dunn13-Feb-06 7:44 

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.