|
The usual stuff: register your class, point InprocServer32 to your dll, typeLib, etc.
Then, in HKCR\Folder\shellex\ContextMenuHandlers you register your class and that's it.
If you use ATL, it will do most of the work for you. (you'll have to manually edit the .rgs file though).
And of course, you have to add your item to the context menu in
YourClass::QueryContextMenu().
Good luck.
alex
|
|
|
|
|
I have a user who is trying to import calendar entries from Outlook 2002 using our software. The following code tries to establish an instance of the application object.
<br />
_ApplicationPtr pOutlook = NULL;<br />
<br />
try<br />
{<br />
HRESULT hr = pOutlook.CreateInstance(__uuidof(Application))<br />
if (FAILED(hr))<br />
MessageBox("Unable to create Outlook instance");<br />
else<br />
{<br />
.<br />
.<br />
.<br />
}<br />
}
When this particular user runs this code, they get the message stating that we were unable to create the Outlook instance. I don't have the ability to send the user a test DLL to get the HRESULT error code. I would like some suggestions on things to look for - reinstall Outlook, turn on some Outlook feature, security settings, etc.
Thanks...
Brigg Thorp
Senior Software Engineer
Timex Corporation
|
|
|
|
|
Im trying to add a referance to a dll wrriten in visual studio 6 to a c# application and Im getting an error saying:"This is not a valid assembly or com component. How can I use this dll?
|
|
|
|
|
|
I have to create a COM object which will be instantiated from a dll. This COM object will be an
interface to a database doing all kinds of data minipulations etc... The trick is that, the dll will
spawn individual threads, and the threads will in instantiate the com object. It is estimated that around
7000 threads will be instantiated. (Yes, it is 7000 !!). My concern is that when antantiated, a connection
must be opened to the DB, which takes "long time" and also the actual instantiation of the com object will
also take long. I need guidence on the mehtodology to be used to create this com object, is this the way
to do it or should I go for an alternative solution. I've read the articles on com pooling but sadly part 2
of the article on this matter does not exist. It seems like a good idea, but dont have enough info on this
matter.
Your help in this regard is appreciated
New problems are set in your path. You must overcome these to be stronger for the problems of the next day. The trick is, never worry about the next day, so give problems a ... hug and thank them ....
|
|
|
|
|
This is just not feasible, unless you are talking about creating 7000 threads across an array of at least 200 CPUs or so.
Connection times are the least of your worries.
On WINTEL systems, one CPU = ONE ACTIVE THREAD at any given time.
Multiple threads are queued across time slices - each thread is allowed to run for maybe 20 ms or so then the CPU switches to the next thread in the queue. You can only create so many threads (not many actually) before you overload the system.
Assuming you could create 7000 threads on a CPU (you can't - not even close) then just to go through the entire rotation to allow each one to run for a SINGLE 20 ms timeslice would take 140 seconds, not counting thread switching overhead.
Not that you could ever get there anyway. Every time you create a new thread, the system allocates stack space, among other things to the thread. You'll run out of memory and kernel resources a long time before you get even close to creating 7000 threads.
Think in terms of something that is actually doable - like maybe 15 threads on a single CPU.
|
|
|
|
|
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?
|
|
|
|
|