|
This is the wrong forum for this.
The COM here means Component Object Model and not COM1, COM2 etc.
Anyway, you can use
HANDLE hComm = CreateFile(L"COM1", GENERIC_READ|GENERIC_WRITE, ...
Then you can use ReadFile(hComm, ... to read from the port.
And WriteFile(hComm, ... to write to the port.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi
I want to find DispIds of procedures of Excel 2007. I am able to find out for following
**************************
MSExcel::AppEvents
--------------------------
WorkbookOpen
WorkbookBeforePrint
SheetChange
WorkbookActivate
SheetSelectionChange
--------------------------
but for
MSExcel::DocEvents)
SelectionChange
I am not able to find out.
Please let me know how to find out these DispIds for this.
Thanks
SNI
|
|
|
|
|
Hello all
I am getting the form objects from internet explorer and want to get all the elements from each form. To do this, I get the form collection from the html document object, get an interface to each form element in the collection then try to get an IID_IHTMLElement interface from the IID_IHTMLFormElement interface in order to get all the elements in the form, as recommended by MS. It all works on my machine and all others I've tried, except that on my friend's pc, the QueryInterface call fails with E_NOINTERFACE. I'm not that proficient in COM, so I wonder if there is something I'm doing wrong here so that it only works on some systems. He assures me that he has IE7 installed so not an old cranky version. Code as follows:
bool ret = true;
CComPtr<IHTMLElementCollection> spForms;
long numForms = 0L;
CComPtr<IDispatch> spDisp;
HRESULT hr = spDoc->get_forms(&spForms.p);
if (FAILED(hr) || !spForms)
{
ret = false;
}
if (ret)
{
HRESULT hr = spForms->get_length(&numForms);
if (FAILED(hr))
{
ret = false;
}
}
if (ret)
{
for (int formNumber = 0; ret && (formNumber < numForms); formNumber++)
{
BSTR bstr;
CString formName;
CComPtr<IHTMLElementCollection> spElements;
CComPtr<IHTMLFormElement> spFormElement;
CComPtr<IHTMLElement> spElement;
long numElements = 0L;
CComVariant vIdx(0, VT_I4);
HRESULT hr = spForms->item(CComVariant(formNumber), vIdx, &spDisp.p);
if (FAILED(hr) || !spDisp)
{
ret = false;
}
if (ret)
{
HRESULT hr = spDisp->QueryInterface(
IID_IHTMLFormElement, (void**) &spFormElement.p);
if (FAILED(hr) || !spFormElement)
{
ret = false;
}
}
if (ret)
{
hr = spFormElement->get_name(&bstr);
if (FAILED(hr))
{
ret = false;
}
}
if (ret)
{
HRESULT hr = spFormElement->QueryInterface(!!!
IID_IHTMLElement, (void**) &spElement.p);
if (FAILED(hr) || !spElement)
{
ret = false;
}
...... etc
}
}
}
|
|
|
|
|
It doesn't sound as if there's anything wrong with your code. E_NO_INTERFACE is technically not a failure, it's a legal response in the COM world. I've had users 'assure me' that nothing out of the ordinary is installed or used when it proves not to be the case. Can you put in some checks in your code to test for the right version of IE or perhaps a version number or similar for the FormElement that you get the E_NOINTERFACE from? Does it support some alternate interface, say IHTMLElementEx? I'm not saying there is such a thing as an IHTMLElementEx interface, it's just a possibility.
|
|
|
|
|
Hi
I called him tonight and got him to check the IE version. It is version 7, same as mine. I also asked him to disable all add-ons temporarily but got the same problem. If we both have IE7 and add-ons are not the problem, what other difference could there be on his system that means he gets the E_NOINTERFACE and I don't?
|
|
|
|
|
I suppose it depends on what he has loaded up in IE at the time.
For any COM error such as E_NOINTERFACE you can look for extended error information that may have been set when the error was generated:
IErrorInfo* pErrInfo = NULL;
HRESULT hr = GetErrorInfo(0, &pErrInfo);
Then use the IErrorInfo methods to obtain details, though there may be no info set to retreive its worth a try.
You may have the same IE7, but presumably you may not have the same forms or elements etc. All I can suggest is have the program get details of the object that returns E_NOINTERFACE to see if you can find anything out based on that information or establish a pattern.
It may be that in an ideal world all objects would implement this interface but in reality it means that you have to accept that there are objects out there that don't for some reason. As a result you have to handle the ones that don't somehow. Currently your loop exits when 'ret' becomes false for any reason, maybe you need to skip that element and move on to the next (or something similar), storing its details etc.
|
|
|
|
|
Thanks for that. I'll try the extended error info to see what it shows me. You're right - it should skip onto the next one if it fails instead of aborting completely.
Both of us are using the same web page to test the program, specifically mailzone.onetel.net.uk which is a simple page containing a single form with a text input element and a password input element. It doesn't seem to matter what the page is though as mine always works and his always fails whatever web page I've chosen. It should be possible to get an interface to an IHTMLElement from the IHTMLFormElement according to the MS documentation, but it won't work on his pc.
|
|
|
|
|
when you delete a file in explorer, you can later undo the delete (restore) the file.
even when you start a second instance of the explorer, the menu with the undo command is updated
correctly in both instances.
i think internaly the shell uses ONE IOleUndoManager.
when you make changes to directories and files (copy, delete, rename...) and use IFileOperation, then your changes are automaticly registered in the undoManager.
My question is, how can i access this IOleUndoManager?
Vista32:
i create a instance of CLSID_ExplorerBrowser.
then i get a IServiceProvider from that browser.
then i do a QueryService(services, SID_SOleUndoManager, IID_IOleUndoManager);
but i get only a E_FAIL from that..(Service not found).
Note: i also programmed a shell namespace extension and i see that the shell
uses internaly the IOleUndoManager.
in msdn i only find the interface documentation.
|
|
|
|
|
I have COM exe server and a dialog based MFC client..The code works well on the same machine..But ,when I copiede exe of the server to the remote machine and registered it and tried to call the server I'm getting Library not found error...This is my import statement..
#import "\\Remoteservername\FileServer.exe"
using namespace FILESERVERLib;
|
|
|
|
|
I'ts a while since I've done any MFC COM, but I'm pretty sure the location of the target of the #import statement is independant of any calls to the actual server. That is, you could have used #import FileServer.exe if a copy of the .exe is in your local directory - it won't have any effect on whether you make a call the server on your machine or another.
It's the code creating and calling the COM object you should be showing.
Have you got the registry settings on the calling machine right so that the system knows which server to call?
If you set your client to use a local server (in the same machine) and then run it on the remove machine does that work?
What about the proxy/stub?
|
|
|
|
|
Hi,
I'm trying to force the out-proc exe server to shutdown automatically within its own proces. Basically I'm trying to implement a safety mechanism if the client application crashes and I would like the server process to kill itself after a period of time. Does anyboy know how I can do this?
Thanks
|
|
|
|
|
I suppose you may do that working on the reference counters of the server interface(s). Anyway it is a bit ugly, since how do you know the client(s) are not more alive (closing the server may cause pending client(s) crashing)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
First of all I must be able to connect to the COM exe on the remote machine...The other issues can be dealt later..My initial step itself is not done...
Thank u...
modified on Tuesday, February 24, 2009 4:51 AM
|
|
|
|
|
I've answered Anthony9887's question, not yours.
On the other hand if *RevathiRamakumar* and *Anthony9887* correspond actually to the same person, then I have a clue about your problems with object identities...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Sorry for the wrong interpretation...Could u help me out to solve my problem..
Thank u..
|
|
|
|
|
Hi,
I have only 1 client to 1 server. I tried releasing all ref counts to 0, but the exe never closes, unless I decrement the _Module.Unlock count, then I receive the following in the debug windown.
INTERFACE LEAK: RefCount = 2, MaxRefCount = 4, {Allocation = 3}
Any ideas? I'm a little lost.
Thanks
|
|
|
|
|
Hi,
I want to write Add in Or Plug-In for PDF reader files. I would like to know is it possible to write in COM / C#? If not then which language we need to use for this?
Thanks
SNI
|
|
|
|
|
Hello there,
i hope this is the correct category, to ask this question:
I am developing a Shell Namespace Extension and am currently looking for a way to command the shell, to remove a shell folder. I know there is the function SHChangeNotify, but from my understanding this just tells the shell, that stuff has happened, but doesnt make the stuff happen.
I tried to use this function for my intentions, but it doesnt seem, as if any memory gets freed and i couldnt find, that the FinalRelease()-function neither of the concerned ShellFolder nor of its subfolders gets called. At this point i may be mistaking due to the windows-explorer instancing so confusingly many objects.
Is there any other function i could use, or any different ideas? There must be another Shell Namespace Extension out there, that eventually encountered the same problem, so i cant imagine this to be unsolvable.
Thanks and greets,
Gernot
|
|
|
|
|
|
* Just by knowing the component's CLSID & the interface's IDs?
Use a component with the "import" directive, that takes information from the .tlb file? <-won't this require any header file?
* Creation using ProgIDs is efficient?
Please verify:
* A COM DLL doesn't mean a component. A COM dll may contain any number of components inside. (that we do by adding simple ATL object into workspace?)//Containment ,aggregation etc.
* A CoClass is a component object. As a COM DLL can contain more components, there'll be more CoClasses accordingly.
|
|
|
|
|
- Just by knowing the component's CLSID & the interface's IDs?
Use a component with the "import" directive, that takes information from the .tlb file? <-won't this require any header file?
the #import creates .tli and .tlh files which are headers
- Creation using ProgIDs is efficient?
it must be slower because it looks at the progid in registry then at the clsid
- A COM DLL doesn't mean a component. A COM dll may contain any number of components inside. (that we do by adding simple ATL object into workspace?)//Containment ,aggregation etc.
yes a COM DLL can have many components inside
- A CoClass is a component object. As a COM DLL can contain more components, there'll be more CoClasses accordingly.
yes with ATL you have no problem, each class factory is instanciated within an OBJET MAP
|
|
|
|
|
grassrootkit wrote: * Just by knowing the component's CLSID & the interface's IDs?
Use a component with the "import" directive, that takes information from the .tlb file? <-won't this require any header file?
A header file will be created during the build process that usually has the .tlh extension.
grassrootkit wrote: * Creation using ProgIDs is efficient?
In comparison to what? The CLSID I presume. Due to how the registry is organized, using the ProgID will require an extra round-trip to find out the CLSID since it's underneath that key in the registry the path to the dll is found.
grassrootkit wrote: * A COM DLL doesn't mean a component. A COM dll may contain any number of components inside.
Correct in the sense that a COM DLL may contain more than one COM server.
grassrootkit wrote: * A CoClass is a component object. As a COM DLL can contain more components, there'll be more CoClasses accordingly.
Yes.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
hopefully we gave the same results
|
|
|
|
|
|
But what does this mean?
#import "C:\Program Files\Common Files\System\ADO\msado15.dll"
|
|
|
|