|
Yes, I agree, thanks for the feedback. Let me explain bit further, My biggest concern
was the connection time, therefore, in CONCEPT THE IDEA was to have a thread pool
of 7000 waiting to be utilized when required. It is estimated that at any time,
avarage 5500 connections will be active.
Your thought on 140 seconds is
actualy shocking to say the least, never kept that in mind.
The project concerns
users requesting sessions from a server via tcp. These session packets (tcp) are
intercepted and monitored while the user is online and certain conditions require
a db update. I am not responsible for the "tcp grabbing" but the idea the developer
have there is to create threads for each session. (there are 7000 users, hence 7000 threads).
The com object I am creating, is only an interface to the db doing some other
manipulations to the data. It was envisaged that this com object will be created
per thread, hence 7000 db connections.
The com object is now created and working, as for the "tcp grabbing part and threads....??"
Well, if you have the time, let me know your thoughts , suggestions.
Thanks again for the info above, surely valuable and informative.
Regards
FJK
|
|
|
|
|
Is it valid to create document in one process and get node info in another process. What pointer I need to pass. I think pointer to COM object or interface are local process.
Thanks.
We yesterday got drunk with Bacchus ...
|
|
|
|
|
Do I need to marshal XMLDOMDocument pointer?
We yesterday got drunk with Bacchus ...
|
|
|
|
|
Hello Alex,
It certainly sounds feasible - creating an XML Dom Document object in one process and then transferring it to another process via COM.
Top of my head : one way to do this would be to create a SINGLETON out-of-process COM ObjectServer (i.e. Exe COM Server). This COM Object would ideally be the one that creates the XML DOM Document which is then sharable across multiple exe clients.
Best Regards,
Bio.
|
|
|
|
|
Hi!
I have to develop BHO that would enable me to replace HTML page that was downloaded by user into another HTML page (say, to the same but with some tags deleted etc). I decided to use ATL, have read some docs, and here is the problem. In Invoke on dispidMember==DISPID_DOWNLOADCOMPLETE I call OnDocumentComplete :
Code:
<br />
HRESULT CSuperHook::OnDocumentComplete(){<br />
USES_CONVERSION;<br />
CComPtr<IDispatch> pDisp;<br />
HRESULT hr=m_spBrowser->get_Document(&pDisp);<br />
CComQIPtr<IHTMLDocument2,&IID_IHTMLDocument2> pHTML;<br />
pHTML=pDisp;<br />
if (pHTML){<br />
hr=pHTML->get_body(&m_body);<br />
if (FAILED(hr))<br />
return hr; <br />
BSTR strHTML; <br />
hr=m_body->get_innerHTML(&strHTML);
hr=Parse(&strHTML,_T("<TR>"),_T("<a href='http://www.codeguru.com/'>Codeguru.com</a>"));
<br />
hr=m_body->put_innerHTML(strHTML);
::SysFreeString(strHTML);<br />
}<br />
return S_OK; <br />
}<br />
Function Parse take source HTML page, replacing text and replaced text as params:
Code:
<br />
HRESULT CSuperHook::Parse(BSTR *source,LPTSTR strSearch,LPTSTR strReplace){ <br />
USES_CONVERSION;<br />
int strSourceLen=SysStringLen(*source);<br />
int strSearchLen=_tcslen(strSearch);<br />
int strReplaceLen=_tcslen(strReplace);<br />
LPTSTR strSource = new TCHAR[strSourceLen+1]; <br />
LPTSTR strNew = new TCHAR[strSourceLen+4000]; <br />
<br />
_tcscpy(strSource, OLE2T(*source));<br />
LPTSTR token,pPrevPos=strSource;<br />
int posSource=0,posNew=0;<br />
while ((token=_tcsstr(strSource+posSource,strSearch))!=NULL){ <br />
_tcsncpy(strNew+posNew,strSource+posSource,token-pPrevPos);<br />
posSource+=token-pPrevPos+strSearchLen; <br />
posNew+=token-pPrevPos;<br />
_tcsncpy(strNew+posNew,strReplace,strReplaceLen); <br />
pPrevPos=token+strSearchLen;<br />
posNew+=strReplaceLen; <br />
}<br />
token=strSource+_tcslen(strSource);<br />
_tcsncpy(strNew+posNew,strSource+posSource,token-pPrevPos);<br />
posNew+=token-pPrevPos;<br />
strNew[posNew]='\0';<br />
<br />
::SysFreeString(*source); <br />
*source=::SysAllocString(T2OLE(strNew)); <br />
delete [] strSource;<br />
delete [] strNew;<br />
return S_OK; <br />
}<br />
So, now on page load in IE (after the load is over) in a browser window in some places (where there must have been "" tag) we can see the link named "codeguru.com". Clicking on it, we redirect to codeguru.com... It seems as if everithing is right, but source HTML code (IE main menu->Tools->Source) have not been changed ! Why ?
Now, I begin to refresh the page, and after two or three refreshs I have buffer overflow (my firewall says that DEVENV.EXE tries to write something to IE address space). Then an error occures in module strcat.asm....
I cannot understand why does it happen, it seems I free all allocated memory !!!
And maybe somebody knows the way to do this task easer or maybe somebody has some workarounds on subj ?
Thanx for attention !
|
|
|
|
|
Hi,
Is there an way i can use enum( or anything that behaves like enum or takes in enum in COM)? i have some parameters that i would like to pass to my COM DLL that have 3 states and i would use enum to represent these states if i was working on C or VB.
Truth is not always popular, but it is always right.
|
|
|
|
|
Sure you can !
Just embed your enum declaration inside your .idl like this:
enum STATE
{
ON,
OFF,
UNKNOWN
};
The STATE enum will be visible inside any COM client referencing the typelibrary.
Hope it helps
GuimaSun
www.nexsun.com.br
NEXSUN TechZone
|
|
|
|
|
For those of us interested in writing Internet Explorer plug-ins that can manipulate the surface of a user-selected web page, can anyone suggest resources with informatin on how to do this in C#?
I am trying to write an IE plug-in that overlays user-defined shapes on top of a web page, and am new to C# and COM. Any help would be greatly appreciated!
Thanks!
|
|
|
|
|
Hi !
I'ld like to use the WebBrowser control as a FileManager, allowing the user to browse his disc etc.
I've found a lot of things about how to use it for browsing webpages. But for the usage as a FilaManager, it looks as if some methods are missing or well hided. I'ld like to set the type of visualization the control uses to represent a directory. It defaults to "Icons". Is there a way to switch it to another representation by code? E.g. "Thumbnail" or "Details"? My pc's explorer displays everything in "Details" view by default. So it does not take explorer's settings. However, the user can switch the representation during runtime by usign the context menu of the control. But if he changes the directory, it switches back to "Icons". :/
Any hint is welcome.
Best regards
Marc
|
|
|
|
|
Rehi !
I got the solution by myself. For those who are interested in how it works:
IDispatch *d_app;
d_app=explorer.get_Application();
IWebBrowserApp *pwba;
d_app->QueryInterface(IID_IWebBrowserApp, (void**)&pwba);
IServiceProvider *psp;
pwba->QueryInterface(IID_IServiceProvider, (void**)&psp);
IShellBrowser *psb;
psp->QueryService(SID_STopLevelBrowser, IID_IShellBrowser, (void**)&psb);
IShellView *psv;
psb->QueryActiveShellView(&psv);
IFolderView *pfv;
psv->QueryInterface(IID_IFolderView,(void**)&pfv);
pfv->SetCurrentViewMode(ViewMode);
pfv->Release();
psv->Release();
psb->Release();
psp->Release();
pwba->Release();
Don't forget to check if QueryInterface succeeds when doing this. I ommited that for readability.
Best regards
Marc
|
|
|
|
|
After reading Michael Dunn's tutorials and a few msdn articles, I got my extension up and written. But I can't get explorer to load it. I've read and re-read the steps for adding the information to the registry but nothing I've done seems to work.
If there's something I'm missing I'd be grateful to hear it.
|
|
|
|
|
Try SDK sample program. If you could get it to work, you will know the problem of your program. For my experience, your registry should set it right. If you do not copy your DLL to system directory, you need to modify HKEY_CLASSES_ROOT\CLSID\{your uuid}\InfoProcServer32\Default point to your shell extension dll. Good luck.
!@#$%^&*()_+
|
|
|
|
|
I have a windowless control for which I need a timer to reset an internal state after a short delay, for highlighting purposes.
I have been led to believe that all I need to do is to use a hidden window to handle SetTimer and KillTimer.
Yet all my attempts to create a hidden window have failed. It seems that I can't register my own window class, because Create fails. (This approach worked fine until I specified a variable to refer to the control in C++ code.) So I tried using a predefined class, CButton. This can't be created when the control is used from VBasic, as CWin::Create needs to know have an application instance, but VBasic supplies this as NULL.
I have found code using ATL which would seem to work, but I am using MFC and can't figure out how the ATL code can be translated.
Is there any practical way to use a timer in a windowless control? Or do I really have to specify a window for the control just for the sake of a timer?
Shraddhan
Tearing my hair out does not help me write better code, but it does ease the pain...
|
|
|
|
|
Did you try RegisterClass() /RegisterClassEx() ?
If your target platform is windows 2000 and later, you can create message only windows. They work like windows, except they have no graphical representations. They're just "identities" (HWND).
Good music: In my rosary[^]
|
|
|
|
|
I was using AfxRegisterClass() and CWnd::CreateEx()
After changing the code to use RegisterClassEx( ) and CreateWindowEx(), everything now seems to work.
What the difference might be, I have no idea.
Thanks for the clue.
Shraddhan
|
|
|
|
|
You're most welcome, and I'm glad that it worked out for you.
Good music: In my rosary[^]
|
|
|
|
|
Hi,
How can I load a char** into a VARIANT?
thanks
|
|
|
|
|
Hello bvais,
I assume that you want to use a VARIANT to store a receiver of a string. You can't load a char** into a VARIANT. The standard way to pass strings in COM is to use BSTRs.
Try using a BSTR* instead. In this case, the type for your VARIANT would be : (VT_BSTR|VT_BY_REF). The specific member in the VARIANT to use is "pbstrVal" (set/get via the V_BSTRREF() macro).
Best of luck,
Bio.
|
|
|
|
|
Hi Bio,
I need to pass an array of strings. How do I do that?
|
|
|
|
|
|
Hello bvais,
Yes, as mentioned by GuimaSun (in an earlier reply), the way to do this is to use a SAFEARRAY of BSTRs.
I have a sample function below that can help you to achieve this :
// CreateSafeArrayFromBSTRArray()
// This function will create a SafeArray of BSTRs using the BSTR elements
// found inside
// the first parameter "pBSTRArray".
//
// Note well that the output SafeArray will contain COPIES of the original
// BSTRs
// inside the input parameter "pBSTRArray".
//
long CreateSafeArrayFromBSTRArray
(
BSTR* pBSTRArray,
ULONG ulArraySize,
SAFEARRAY** ppSafeArrayReceiver
)
{
HRESULT hrRetTemp = S_OK;
SAFEARRAY* pSAFEARRAYRet = NULL;
SAFEARRAYBOUND rgsabound[1];
ULONG ulIndex = 0;
long lRet = 0;
// Initialise receiver.
if (ppSafeArrayReceiver)
{
*ppSafeArrayReceiver = NULL;
}
if (pBSTRArray)
{
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = ulArraySize;
pSAFEARRAYRet = (SAFEARRAY*)SafeArrayCreate
(
(VARTYPE)VT_BSTR,
(unsigned int)1,
(SAFEARRAYBOUND*)rgsabound
);
}
for (ulIndex = 0; ulIndex < ulArraySize; ulIndex++)
{
long lIndexVector[1];
lIndexVector[0] = ulIndex;
// Since pSAFEARRAYRet is created as a SafeArray of VT_BSTR,
// SafeArrayPutElement() will create a copy of each BSTR
// inserted into the SafeArray.
SafeArrayPutElement
(
(SAFEARRAY*)pSAFEARRAYRet,
(long*)lIndexVector,
(void*)(pBSTRArray[ulIndex])
);
}
if (pSAFEARRAYRet)
{
*ppSafeArrayReceiver = pSAFEARRAYRet;
}
return lRet;
}
Then, you can use the above function in your code as demonstrated below :
#include <comdef.h>
int main()
{
// Define an array of BSTRs which are initialized via _bstr_t.
BSTR bstrArray[] =
{
_bstr_t(L"BSTR 01").copy(),
_bstr_t(L"BSTR 02").copy(),
_bstr_t(L"BSTR 03").copy(),
_bstr_t(L"BSTR 04").copy(),
_bstr_t(L"BSTR 05").copy()
};
SAFEARRAY* pSAFEARRAY = NULL;
// Create a Safe Array of BSTRs which are copies of the elements
// of bstrArray.
CreateSafeArrayFromBSTRArray
(
bstrArray,
sizeof(bstrArray)/sizeof(BSTR),
&pSAFEARRAY
);
// Destroy the safe array object pSAFEARRAY.
// SafeArrayDestroy() will also destroy the
// BSTRs created via CreateSafeArrayFromBSTRArray().
// pSAFEARRAY.
SafeArrayDestroy(pSAFEARRAY);
pSAFEARRAY = NULL;
return 0;
}
Best Regards,
Bio.
|
|
|
|
|
Lim Bio Liong wrote:
_bstr_t(L"BSTR 01").copy()
Just out of curiosity.. why this, when there's SysAllocString() ?
Good music: In my rosary[^]
|
|
|
|
|
Hello Jorgen,
Yes, Jorgen, SysAllocString() should be used. I recently used _bstr_t in a similar manner (for R&D purposes) as the sample code for bvais and developed something of a habit .
Thanks for pointing it out, Jorgen.
Best Regards,
Bio.
|
|
|
|
|
I am using TotalRecorder(ww.highcriteria.com) in my application developed in C#. My Application inetract with TotalRecorder through COM. Total Recorder provides a sample in VC 6.0 for saving the recorded file at a specified folder location. I have converted the VC 6.0 code to C#, everything is working fine except when i call the method that saves the recorded files, the method takes variant as input, while the wrapper for this method generated by VS 2003 takes object as input. I passed him with the required parameters but it gives error 'Method Not Implemented'. Both the codes are given below. Please help me in conerting this VC code (variants) to C# (objects)
This is the code in VC 6.0
_variant_t vartFileName;
VARIANT vFmt;
vartFileName = cFileName;
vFmt.vt = VT_ERROR;
vFmt.scode = DISP_E_PARAMNOTFOUND;
g_pTRDoc->SaveAs(vartFileName, vFmt);
I have converted this in C# like this
string FileName = "c:\test.wav";
rec.ActiveDocument.SaveAs(FileName,System.Reflection.Missing.Value);
Thanks
I am using TotalRecorder(ww.highcriteria.com) in my application developed in C#. My Application inetract with TotalRecorder through COM. Total Recorder provides a sample in VC 6.0 for saving the recorded file at a specified folder location. I have converted the VC 6.0 code to C#, everything is working fine except when i call the method that saves the recorded files, the method takes variant as input, while the wrapper for this method generated by VS 2003 takes object as input. I passed him with the required parameters but it gives error 'Method Not Implemented'. Both the codes are given below. Please help me in conerting this VC code (variants) to C# (objects)
This is the code in VC 6.0
_variant_t vartFileName;
VARIANT vFmt;
vartFileName = cFileName;
vFmt.vt = VT_ERROR;
vFmt.scode = DISP_E_PARAMNOTFOUND;
g_pTRDoc->SaveAs(vartFileName, vFmt);
I have converted this in C# like this
string FileName = "c:\test.wav";
rec.ActiveDocument.SaveAs(FileName,System.Reflection.Missing.Value);
Thanks
Basit Tanveer
Software Engineer
|
|
|
|
|
|