Article View: borland.public.cppbuilder.nativeapi
Article #3647Re: TCppWebBrowser + LOCAL_SYSTEM account
From: Remy Lebeau (TeamB)
Date: Thu, 11 May 2006 01:34
Date: Thu, 11 May 2006 01:34
69 lines
3123 bytes
3123 bytes
"Mike Collins" <its@TheBottomOfThePost.com> wrote in message
news:44628b1d$1@newsgroups.borland.com...
> I've never had to make this call directly when i've used the
> TCppWebBrowser before though.
Under many situations, CoInitialize() gets called automatically during
application startup.
> I trying to work out the best place to place these two calls
> CoInitialize() and CoUninitialize().
The best place is at the beginning/end of the calling thread. However,
since your code is in a DLL, the calling application controls the threads
that call into the DLL, so the application should be calling CoInitialize()
before then calling your DLL.
> if (CoInitialize(NULL)==S_OK)
CoInitialize() can also return S_FALSE instead of S_OK. S_FALSE is not an
error. You should be using the SUCCEEDED() macro instead of testing for
S_OK specifically.
> __finally
The order is you catch and __finally blocks is a bit wrong. Use this
instead:
try
{
if( SUCCEEDED(CoInitialize(NULL)) )
{
try
{
HelpOptDlg = new THelpOptDlg(NULL);
try {
iRtn = HelpOptDlg->ShowModal();
}
__finally
{
delete HelpOptDlg;
HelpOptDlg = NULL;
}
}
__finally
{
CoUninitialize();
}
}
else
// error...
}
catch (const Exception &exception)
{
MessageBox(NULL, exception.Message.c_str(), "TCppWebBrowser
Exception", MB_OK|MB_ICONERROR|MB_TOPMOST);
}
> is it better to call it "globally" when the DLL first starts up i.e. in
DLLMain?
CoInitialize() has to be called on a per-thread basis. Although DllMain()
is called whenever the DLL is loaded into a particular thread, you have to
be careful because DLL_THREAD_ATTACH is not triggered for existing threads
when the DLL is loaded by LoadLibrary().
Gambit
Technical Details
Message-ID:
<44629515$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4460d27d$1@newsgroups.borland.com> <4460ea6b@newsgroups.borland.com> <446216ce$1@newsgroups.borland.com> <g26462dc5l9t2u33i2d6c9lmnoe4u1uvm2@4ax.com> <44628b1d$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d67fc4a2c4ab8bd3 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <4460d27d$1@newsgroups.borland.com> <4460ea6b@newsgroups.borland.com> <446216ce$1@newsgroups.borland.com> <g26462dc5l9t2u33i2d6c9lmnoe4u1uvm2@4ax.com> <44628b1d$1@newsgroups.borland.com> Subject: Re: TCppWebBrowser + LOCAL_SYSTEM account Date: Wed, 10 May 2006 18:34:04 -0700 Lines: 71 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <44629515$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1147311381 68.69.17.41 (10 May 2006 18:36:21 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail