|
Hi!
I wrote a context menu handler for a program which runs from an usb disk. The program is running fine on my PC, but some of my friends are complaining that as soon as the software is installed in their usb disk and the program is run their context menu goes away...and it gets ok when the unplug the usb disk again....any idea why this would be happening ?
Thanks.
kane
"Some guys hack just to get themselves a girlfriend.What a pathetic reason huh ?"
|
|
|
|
|
Hello code project community, I have following question.
I would like to access a com component ( all the funcitons within the COM component -- that basically access the database on the machine where COM is registered ) registered on a remote machine through a web page. How should i communicate with remote COM component from a web server ?
Scenario : Computer A -- WEB SERVER, computer B -- a client on which a com component is registered and database resides.
I would like to access a COM component from machine A, get result from database through COM object funciton call, and write it to the file on the server ( computer a )??? Any idea??
Can I make a remote call to COM component?
I am thinking that you could do it through .net remoting, but then client needs to run a listner on his/her machine. Another way is that You could have activex object accessing client, but then i need to send result back to server from client. Is there any nice way to send entire object from client browser to server?
Any suggesitons would be very welcome and very much appreciated. Thanks a lot.
Manish
|
|
|
|
|
I am lerning COM and this is as simple as I can get.
Here is my interface.h file
/////////////////////////////////////////////////////
extern "C" const IID IID_IMath;
// {2BD8F185-7D1C-4058-9B98-C29E343E858F}noblk
extern "C" const IID IID_IMath =
{ 0x2bd8f185, 0x7d1c, 0x4058, { 0x9b, 0x98, 0xc2, 0x9e, 0x34, 0x3e, 0x85, 0x8f } };
interface IMath
{
public:
virtual long Add(long n1, long n2) = 0;
virtual long Sub(long n1, long n2) = 0;
};
////////////////////////////////////////////////////
but if I add the math.cpp to my project is gives me the following
error message:
fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.
////////////////////////////////////////////////////////
here's my math.cpp
/////////////////////////////
#include "interface.h"
#include <iostream.h>
class CMath : public IMath
{
public:
CMath();
~CMath();
virtual long Add(long n1, long n2);
virtual long Sub(long n1, long n2);
};
CMath::CMath()
{
cout << "\nCMath Constructor called." << endl;
}
CMath::~CMath()
{
cout << "\n CMath Destructor called" << endl;
}
long CMath::Add(long n1, long n2)
{
return n1 + n2;
}
long CMath::Sub(long n1, long n2)
{
return n1 - n2;
}
I HAVENT BEEN ABLE TO FIND THE SOURCE OF THIS ERROR, Please Help!
Thanks
|
|
|
|
|
correction:
2nd line of math.cpp should read "#include <iostream.h>
|
|
|
|
|
Hi,
I've to develop 3 ActiveX controls.
Server - this will read the data and updates the data continuosly
ClientA - Gets the part of updated data from the server
ClientB - Gets the part of updated data from Server
There can be many instances of ClientA and ClientB and only one insatnce of the server in a contianer.
Can any one suggest me the best design pattern to implement this in VC++ or VB and how to implement this?
Thanks in advance!
VK
|
|
|
|
|
|
Not sure if this answers your question exactly, but here is some generalk information.
ActiveX DLLs and OCXs (which are nothing more than DLLs with a special wrapper) are always loaded into each process that calls them, so you cannot enforce a single instance of a server using either. you need to use an ActiveX EXE instead.
An ActiveX EXE component runs as a single instance by design with no special development on your part. In other words, the first time any client calls an ActiveX EXE, one instance of the server will be created. All additional calls by any number of clients will be handled by the one instance of the ActiveX EXE server that is already running.
The above only applies to the server component itself.
Suppose for example, you have 10 ClientA instances that call Server.EXE and request some class MyServerClass. The first ClientA that calls the Server.EXE will cause a single running instance of Server.EXE to be instantiated. When the remaining 9 ClientA components request a MyServerClass object, ALL of those requests will be serviced by the single instance of Server.EXE already running. BUT you will still have 10 instances of MyServerClass - one for each ClientA request - all being provided by the SINGLE instance of Server.EXE.
Assuming that what you really want is 10 ClientA components that all have a reference to a SINGLE instance of MyServerClass, provided by a SINGLE Server.EXE, then you need to also implement MyServerClass as a Singleton. This is easy to do in C++, a little harder to do (but still possible) in VB.
Do a web search on Singleton and ActiveX EXE and you should find plenty of examples.
Hope this helps.
Robert
|
|
|
|
|
My registry set up as follow:
REGEDIT4
[HKEY_CLASSES_ROOT\CLSID\{A138EF7F-0930-4bc5-B1AC-33E1D0415BEE}]
@="Shell Extension"
[HKEY_CLASSES_ROOT\CLSID\{A138EF7F-0930-4bc5-B1AC-33E1D0415BEE}\InProcServer32]
@="scshellext.dll"
"ThreadingModel"="Apartment"
[HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\{A138EF7F-0930-4bc5-B1AC-33E1D0415BEE}]
@="Shell Extension"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved]
"{A138EF7F-0930-4bc5-B1AC-33E1D0415BEE}"="Shell Extension"
For this setup, any file selection system will call my context menu entry. But select the directory, system will not call. Does any one know how to setup the registry that will cause the system to call the context menu when the directory has selected?
Thank you for the help in advance.
!@#$%^&*()_+
|
|
|
|
|
There is a key for the directory:
[HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers\{A138EF7F-0930-4bc5-B1AC-33E1D0415BEE}]
@="Shell Extension"
!@#$%^&*()_+
|
|
|
|
|
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
|
|
|
|
|