|
No need for anyone to spend any more time on this --
Sorry if anyone spent time on this, I think there is code on this website in the articles that would help me. In the COM section, "STL Compliant Class for SafeArrays", the code returns safearrays from a COM object, which was my problem. There may be other articles as well. I will look at that to find out what I am doing wrong, so no need for anyone to look at this any further, thanks for the effort.
David Spain, C++ Applications Programmer
|
|
|
|
|
I want to incoporate vbscript and jscript in my MFC application. What is the correct method of implementing IAcitveScriptSite and IActiveScriptSiteWindow with ATL form VS.NET ??
Thanks
Michael
|
|
|
|
|
I have a UART driver (Remon Spekreijse made 97(!)) and when i toggle with suspend/resume a thread created in the UART driver I get unhandled exception messages when in release mode. It works if I just toggle once (I create the thread and then suspend it) but if I suspend it again I get the "unhandled exception". Maybe the driver is missing some code...I'm not an expert on the threading part, what should I look for in my code??
And also, does someone know were to find a good working UART driver that is newer that the one I have that is from 97 heh...
Dejan.
|
|
|
|
|
Using ATL/Windows 2000 I have created an .EXE ATL (simple object) COM object named EXEServer, I then created a (client) MFC .exe to try and create the .EXE ATL COM server object on the same machine using CoCreateInstance(....,CLSCTX_LOCAL_SERVER....), shown below - no luck !!!!
I get the HRESULT return error E_NOINTERFACE when I do a simple CoCreateInstance on the ATL .EXE COM object via the client. What is going wrong ? How can I fix this...?
I've checked both the registry AND OleViewer and the ATL COM ServerEXE IS there and seems to be active....what am I missing.....? please help me I am going crazy...
// The client MFC code...
BOOL CClientEXEDlg::OnInitDialog()
{
....
CoInitialize(NULL);
IExeServer* pIHelloWorld = NULL;
HRESULT hr = CoCreateInstance (CLSID_ExeServer,
NULL, CLSCTX_LOCAL_SERVER,
CLSCTX_,
IID_IExeServer,
reinterpret_cast<void**>(&pIHelloWorld));
BSTR bstrMsg = NULL;
void *pMsgBuf;
::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
hr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT ),
(LPSTR)&pMsgBuf,
0,
NULL );
AfxMessageBox((LPSTR)pMsgBuf);
if (hr == E_NOINTERFACE)
{
AfxMessageBox("CLASS_E_NOINTERFACE"); // this error is always
// there
}
if (FAILED(hr))
{
AfxMessageBox("FAILED");
CoUninitialize();
EndDialog(TRUE);
return TRUE;
}
else
{
m_edit = bstrMsg;
::SysAllocString(bstrMsg);
}
hr = pIHelloWorld->SayHello(&bstrMsg);
pIHelloWorld->Release();
UpdateData(FALSE);
// TODO: Add extra initialization here
CoUninitialize();
return TRUE;
}
john s.
|
|
|
|
|
I just started messing around with COM and am having this same exact problem. Are there extra settings for an out-of-process .exe server that I don't know about? Anyone?
|
|
|
|
|
Thank you!
I hope you could help me.
-----Method != Objective,COM != Panda-----
|
|
|
|
|
.....SetSite(IUnknown *pUnkSite)
{
IOleWindow *pOleWindow = NULL;
m_hWndParent = NULL;
if (SUCCEEDED(pUnkSite->QueryInterface(IID_IOleWindow, (LPVOID*)&pOleWindow)))
{
pOleWindow->GetWindow(&m_hWndParent);
pOleWindow->Release();
}
}
#define MOSTLY_LEAN_AND_MEAN
|
|
|
|
|
Thank you!
|
|
|
|
|
I am developing an ATL server that will run on several remote systems. How can I pick a server to connect to at run time? I know that I can use DCOM configuration to specify the implementation location before running my application but I want to allow a user to select from a list of computers or IP address that house the server while the client is running. How do I tell ATL where the server is located at run time?
Thanks.
|
|
|
|
|
Use CoCreateInstanceEx and pass it the machine name selected.
|
|
|
|
|
Thats great!
Thanks Mark.
|
|
|
|
|
Hi all,
I have a few (possibly nieve) questions regarding the efficiency of calls to in proc COM methods vs. standard C++ function calls.
I've inherited a project which had a master computer delegating some functionality to a few clients, using DCOM. We are now implementing all functionality in one monolithic app. The way I see it I have two options; either use the original COM dll's and invoke them as INPROC_SERVERs, or rip out the non-COM parts of the dll code and put it into C++ classes in my main app.
It would be easier to just use the dll's as they are - they work just fine, but I'm concerned about the efficency aspect. My app will be invoking methods in the order of 100 calls per second.
I would like to know some opinions as to what kind of performance hit I can expect in using COM vs. standard C++ function calls.
As I said, I have very little knowledge of COM, so this could be a rather dumb question
Any advice would be really appreciated.
TIA,
Pete
|
|
|
|
|
If you already have the interface in question, then COM is just like calling any virtual function.
Well, that is unless you are talking about invoking methods via IDispatch.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
>If you already have the interface in question, then COM is just like calling any virtual function
True only if calls are made within the same com apartment, otherwise they will be marshalled
|
|
|
|
|
i am doing a visual c++ poject.the project involves 3 menus.i have the main dialog box with 2 buttons which represent selections one can make by clicking.if one option is clicked i want to know how to call another dialog box which has the operations i want to carry out.please help me i am in need of it.or you can tell me the website to go to which has the information
jinguri
|
|
|
|
|
Your question is in your COM forum,Do you use MFC or ATL?
shingai wrote:
if one option is clicked i want to know how to call another dialog box which has the operations i want to carry out
You can create two different dialog box,and in each event handler of buttons create on of them.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
So if you use MFC,with dialog editor create two different dialog and in each button handler create one like this:
CYourDialg1 adlg;
adlg.DoModal();
IN another one:
CYourDialog2 adlg;
adlg.DoModal();
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
My equipment:
Workstation:
Win2k Prof. OS
Visual C++ 6.0
Platform SDK November 2001
Server:
Win2k Server OS
Name: iras
Domain: htlpinkafeld.at
TestUser: testuser@htlpinkafeld.at
Password: none
My Problem:
Let's imagine a user at the workstation wants to set up a connection with the server. The user double clicks the server icon and he will be asked for an username and password. He enters testuser@htlpinkafeld.at and no password. He will get connected and everything is fine. Ok.
I do this whole stuff in my program with the following function:
WNetAddConnection2(...); Well it works!
The disadvantage is that only one user can be connected to the server at the
same time. I found out that every process which trys to work with the server after the connection is established has to use this connection and not a other connection else because there can only one connection at a time. But i have heard that this could be handled with COM Interfaces. I am not a beginner with programming COM Interfaces but i can't find out how this can be done!!
What i want is to get access to the server with more than user at the same time!!!! It is possible but how ?????
Please help me!
|
|
|
|
|
Can I use the OLECMDID_SAVEAS without prompting the user?
How can i submit the path to store the webpage on the disk to this function?
|
|
|
|
|
I'm just learning ATL COM and I'm trying to wrap my head around the world of strings. I'd appreciate any form of help anybody can spare.
For example, I have a class and I want to give it a private data member that will hold string data. Like a "FirstName" or "LastName". When using COM, what data type should be used for this purpose? Should I use a BSTR or some other string type?
class CMyType {
//lots of other ATL stuff
private:
BSTR firstName;
};
Is this ok to do or should I be keeping string data in some other format? Do I need to do anything to make sure the BSTR data gets cleaned up correctly?
To extend this question a bit, is there such a thing as "Best Practices for Win32 strings"? As in, when should one use (or better yet, NOT use) one string type in favor of another? Since my C++ experience is nearly all in "vanilla" C++, I've always used STL strings, but I'm seeing that STL strings just don't cut it in Win32...
Thanks for the help!
|
|
|
|
|
BSTR strings are a special type of string. Even though they look like UNICODE strings, they have to be managed using the ::SysFreeString, ::SysAllocString, etc routines.
So, in your destructor, don't forget to call ::SysFreeString.
You can also use CComBSTR (spelling??) to manage the BSTR.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I tried using CComBSTRs in my class but I had some strange things happening when I did that made me switch back to straight BSTRs. When I accessed the property the CComBSTRs were storing the first time from a skeleton VB project, they worked great. Any subsequent attempts to get the property only returned an empty string (""). Not sure what was going on there. Any thoughts?
Also, is there a way to test if a BSTR has been allocated before calling ::SysFreeString() on a BSTR? Or, can you safely call ::SysFreeString() on a BSTR that hasn't been ::SysAllocString()'d yet?
|
|
|
|
|
First, when you were returning your CComBSTR to the VB app, were you making a copy of the string? If not, then the VB very well could have been deallocating the string.
You should set your pointer to NULL when it isn't pointing to an allocated string. Thus in your destructor you can check for NULL to see if you need to free it. Otherwise, you might try to free someone else's memory or invalid memory and crash the program.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Also You can use bstr_t ,it is very easier to use
it.It doesn't need to use SysAllocString() and SysFreeeString() for it.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Hello gurus,
I want to connect to the events of a custom browser that basically hosts IE webbrowser control, from my application. After the user launches the custom browser,I want to be able to detect events like OnNavigate,DocumentComplete etc. How can this be done? Would appreciate any help, ideas and code.
TIA.
#define MOSTLY_LEAN_AND_MEAN
|
|
|
|