|
ATL is nothing like MFC. ATL was written to make life easier for COM programmers. The only gui stuff in ATL was added to make writing ActiveX controls easier. With ATL you can pretty much create a simple COM object like you seem to need just by running the wizard.
As somebody who learnt COM the hard way, I really do suggest that you use ATL rather than having to write everything from scratch.
Michael
|
|
|
|
|
How can I detect the creation of COM "Random RPC threads" ??
This is something I would really like to know, since I would like to be able to notify some other threads in my app when this happens.
Cheers
Espen
|
|
|
|
|
Hi,
We are trying to use a DCOM server on Windows 95, but we are having some troubles. Ever literature says that the server need to be already launched on the remote machine (Windows 95). "DCOM95 does not perform remote activation. Therefore, the server needs to be running before a remote client can connect to it". The problem is that we have no idea how to run the server before the client connection. May someone help us?
Thanks in advance,
Guaty.
|
|
|
|
|
hey man,
there are s many possibilities to do that
autostart
autoexec.bat
Load in system.ini
etc
There are more than 12 options to start an app on boot time with Windows 9x.
Be aware, if you dismiss the connection to your EXE server, and its
the last connection it will terminate. From that on you have no way to
autostart it again. Therefore I would tweak reference counting of the server if running on Windows 95, if I where you.
|
|
|
|
|
Hi,
Sorry, I forgot to say... I´m not using an EXE server, I´m using a DLL server. When I use it on a Windows 2000 server, I need to create a subkey "DllSurrogate" in the AppID register key. When the client connects, the surrogate "dllhost.exe" starts the DLL server. The problem is that in the Windows 95, the server needs to be already running. If the server is a DLL, what can I do?
Thanks,
Guaty.
|
|
|
|
|
Hi,
I think the answer should be pretty obvious, just make a small executable that creates an instance of your server object and run it on your Windows 95 machine.
Cheers
Espen
|
|
|
|
|
Is it possible to change full ActiveX control's size (extents) from inside control at run-time, sort of notifying the container about the change in size, so then the container would call GetExtent and the control would let him know of its prefferd size.
BeAlex
|
|
|
|
|
I have a com object generated with the ATL com wizard (VC++ 5.0) with the following method:
HRESULT Test([out] BSTR* pOutput);
But the ITypeInfo interface of this com object always report the type of its parameter as VT_PTR (26, pointer type), instead of VT_BSTR|VT_REF. In fact, any pointer parameter (long*, short*, etc.) will be reported as having type VT_PTR.
My question is, is this a bug in the implementation of the ITypeInfo interface? Any help is appreciated. Thanks.
|
|
|
|
|
Never mind. It's a problem in my code.
|
|
|
|
|
I have a dll which has a function returning BSTR like this:
CComBSTR str( OLESTR("Return") );
return str.Copy(); // This is because // otherwise string is freed here.
And when calling from VB I only get back the first letter "R". By replacing code with:
return ::SysAllocStringByteLen( "Return", 6 );
...works Ok. ATL uses SysAllocString in its constructor in first case. Why it is not working properly.
|
|
|
|
|
why not like this?
fun(BSTR *bstr)
{
CComBSTR str("returnt");
*bstr = str;
//or
*bstr = L"return";
}
|
|
|
|
|
You are correct, that will do the work. BSTR as a return values was only cause the similarity of other functions in the same source file for different clients (like regural Win dll). Still wondering the original problem, could it be something related to unicode vs. Ansi character set ?
|
|
|
|
|
I had the same problem. I believe you are right about the unicode. Its a 2 byte per character format. If using English, every other byte is zero!
If you convert it to char * or CString the whole string should show up.
CString s((char *) (_bstr_t) bstr);
|
|
|
|
|
What I need to do install a component on the client machine ?
Which dll´s I need to install on the client machine to support on the component instalation ?
When I use regsvr32.exe, occur different hind of errors, depending the operational system (Win NT, Win 95)
Thanks in advance,
Guaty.
|
|
|
|
|
If your component has dependices ( atl.dll,C Runtime, etc) make sure that they are there on the client machine.
Otherwise regsvr32 should work fine.
Deepak Khajuria
|
|
|
|
|
I am working on a project where I need to Launch another program with command Line parameter. The program is MTRUN.EXE from Rational Visual Test. My code works fine on NT and 98 and Win2000 (no Service pack) but it fails on Win 2000 SP1 and SP2 and Win2000 Server.
It will actually launch MTRUN.EXE but then MTRUN.EXE will prematurely die/exit. If I put a break point at the line that will call "CreateProcess" or SHELL, and then use F8, it will work fine...launch MTRUN.EXE and Continue execution as required.
Please what will I do to make it work fine at run mode on Win2000
Bob
|
|
|
|
|
Does anyone have a prefered method for creating threads in COM objects, CreateThread vs. _beginthreadex?
I seem to remember something about CreateThread being the prefered method, but a co-worker is argueing for _beginthreadex. _beginthreadex calls CreateThread anyway correct?
|
|
|
|
|
COM or not, the rule is:
If you are going to use CRT functions, then, by all means use _beginthreadex; if not, use CreateThread.
In COM, developers often avoid CRT (there is a macro in ATL to minimize the CRT overhead), and that's why they use CreateThread.
I vote pro drink
|
|
|
|
|
Hi Mark Nischalke,
No, the prefered method is _beginthreadex.
See Jeffrey Richter Win32 Article MSJ July 1999
Cheers
Ghazi
|
|
|
|
|
Thanks Ghazi, the article answered the questions.
|
|
|
|
|
Hi,
I found a mem leak problem with IWbemLocator::ConnectServer() interface
To reproduce this, compile and link and run the following program on Win2k SP2. I am using purify, so no need to run many rounds. But you do not have purify. Monitor it thru perfmon, you need loop thru many e.g. 20 different computers in your domain, and you will see each round you got around 12k mem leak.
If you think there is a delay to free issue change the Sleep call to make
it sleep for long enough, I tried 3 days. and it still leaks!!!
Any help would appreciated.!
***************************************************************
#define POLARITY
#define _WIN32_DCOM
#include <comdef.h>
#include <iostream>
using namespace std;
#include <iomanip>
#include <windows.h>
#include <chstring.h>
#include <chstrarr.h>
#include <assert.h>
#include <wbemidl.h>
#include <winbase.h>
int main(int argc, char **argv)
{
HRESULT hres;
START:
hres = CoInitializeEx(0, COINIT_MULTITHREADED); // Initialize COM.
if (FAILED(hres))
{
cout << "Failed to initialize COM library. Error code = 0x"
<< hex << hres << endl;
return 1; // Program has failed.
}
hres = CoInitializeSecurity(NULL, -1, NULL, NULL,
RPC_C_AUTHN_LEVEL_CONNECT,
RPC_C_IMP_LEVEL_IDENTIFY,
NULL, EOAC_NONE, 0
);
if (FAILED(hres))
{
cout << "Failed to initialize security. Error code = 0x"
<< hex << hres << endl;
CoUninitialize();
return 1; // Program has failed.
}
IWbemLocator *pLoc = 0;
hres = CoCreateInstance(CLSID_WbemLocator, 0,
CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) &pLoc);
if (FAILED(hres))
{
cout << "Failed to create IWbemLocator object. Err code = 0x"
<< hex << hres << endl;
CoUninitialize();
return 1; // Program has failed.
}
IWbemServices *pSvc = 0;
for(int j=0;j<1;j++)
{
// Connect to the root\default namespace with the current user.
WCHAR Namespace[256];
swprintf(Namespace, L"\\\\%s\\root\\cimv2", L"tester");
hres = pLoc->ConnectServer(
_bstr_t(Namespace),
_bstr_t(L"user"),
_bstr_t(L"pwd"),
0,
0,
_bstr_t(L"NTLMDOMAIN:development"),
0,
&pSvc
);
if (FAILED(hres))
{
cout << "Could not connect node " << j << " Error code = 0x"
<< hex << hres << endl;
//pLoc->Release();
//CoUninitialize();
//return 1; // Program has failed.
}
else
{
cout << "Connected to WMI" << endl;
pSvc->Release();
}
}
pLoc->Release();
CoUninitialize();
Sleep(120000);
return 0; // Program successfully completed.
}
|
|
|
|
|
I'm a COM newbie and know very few of this topic.
What ist the difference between COM, DCOM, and COM+, and how do I best start learnig it ? Can you suggest any books ?
|
|
|
|
|
To learn what is the difference between these terms, following are some suggested books:
"Atl Developers Guide"
"The COM and COM+ Programming Primer"
"Mastering COM"
Regards,
ShadiK.
Shadi Al-Kahwaji
|
|
|
|
|
|
Essential COM by Don Box. The COM bible as far as I'm concerned and Don is the COM god.
ATL is the best way of developing COM objects. There are plenty of useful articles on getting started on MSDN in the Dr Gui columns.
Michael
|
|
|
|