|
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
|
|
|
|
|
Inside COM by Dale Rogerson is good.
It explains all the basics of COM thoroughly first without relying on ATL or MFC. Good if you want to learn basic COM before learning ATL.
Dave.
|
|
|
|
|
Thanks a lot for your replies.
|
|
|
|
|
I have a server and a client running on diffrent machines.
I want the client to activate methods on the server's machine.
is comm the answer for that?
if it is, how do i do it?
Yoav Zur
mailto: yoav_zur@mediguide.co.il
|
|
|
|
|
Hi,
Yes, COM is the answer. You can use Distributed COM (DCOM), or if you are using Windows2000 you can implement COM+ for this purpose. How you do it needs a lot of training on DCOM or COM+, I recommend the second one, which is COM+, if you have Windows2000 OS. To do this, take one of the good books like "Mastering DCOM", or "The COM and COM+ Programming Primer" and start from there.
Regards,
ShadiK.
Shadi Al-Kahwaji
|
|
|
|
|
I am trying to register a Shell Extension I write via:
regsrv32.exe myshell.dll
But I'm getting an error: 0x80070716
I can't find this anywhere and attempts to break it apart don't reveal anything. I'm using sample code from a project on this site and the sample project runs fine. At this point all I've changes is the GUIDs and the name of the Class. I've double and triple checked that my GUIDs are correct and nothing else is wrong. But, I keep getting this error code.
Can someone help me in figuring out what the problem is?
Thanks, RZ
|
|
|
|
|
The VC error lookup util says "The specified resource name cannot be found in the image file."
--Mike--
http://home.inreach.com/mdunn/
#include "witty_sig.h"
your with and
|
|
|
|
|
Well, that clears it right up!
I did stumble on this while looking at winerror.h, but figure it didn't apply. What image file? There is only one bitmap resource, and it looks fine. What other images could they be talking about? OR does "image" not really refer to a graphical image? Either way, I'm still lost and frustrated.
RZ
|
|
|
|
|
I was hoping that error would be meaningful to you. You can debug the registration process by going to your project settings, Debug tab, and set regsvr32.exe as the "executable for debug session." Then set a breakpoint at DllRegisterServer() and start single-stepping.
--Mike--
http://home.inreach.com/mdunn/
#include "witty_sig.h"
your with and
|
|
|
|