|
Hi guys,
I am new to COM. Any suggestions on how I should proceed.:->
I need tips on how to write my first simple hello world program using COM.
Thanks
Owner Drawn
--Nothing special
|
|
|
|
|
Hi,
1. There are a lot of resources here, in The Code Project. Use them.
2. If you have the posibility of buying books or taking them from anywhere, I recommend you Essential COM, from Don Box. The first chapter is the best introduction to COM I've ever read. There are a lot of books. Search in Amazon and just read the reviews.
In my case I've found some 2'nd hand copies of
Essential COM,
Inside Distributed COM (Gut Eddon, Henry Eddon) and
Developer's Workshop to COM and ATL 3.0.
3. Use the forums. This one and ...
microsoft.public.vc.atl
microsoft.public.win32.programmer.ole
4. be patient...
-- modified at 12:35 Friday 11th November, 2005
3 and a half. Here you can find some links of interest:
http://www.sellsbrothers.com/links/#unmanlinks[^]
|
|
|
|
|
Owner drawn wrote: need tips on how to write my first simple hello world program using COM.
Perhaps more information on the nuts and bolts of how one actually *writes* this software may be helpful.. I have a step-by-step DCOM tutorial, where I build a simple server which says "Hello, world!" back to the client, may help put some of this in practical perspective...
The tutorials are written as a series of separate articles, called Steps, which cover the major breakpoints in the development of the system.
Step 1 of the tutorial for VC 6 is at
http://www.codeproject.com/com/HelloTutorial1.asp[^]
And Step 1 of the turtorial for Visual C++.NET 2003 is at
http://www.codeproject.com/useritems/HelloTutorial1NET.asp[^]
I tried to write the tutorials in Microsoft-ese, so you can follow along as if you were reading the Scribble tutorial. The VS.NET version is still a work in progress; that's why it's still in "Unedited User Constributions."
Not all the Steps have been written for the VS.NET version yet. But I am working on it!
Stay tuned!
Sincerely Yours,
Brian Hart
Department of Physics and Astronomy
University of California, Irvine
|
|
|
|
|
Hi,
Please help on the following issue.
How can I creat a BSTR using a char array, containing NULLS . I am failing to do it this ways:-
void CEquipMain::varTest(){
char str[] = {'L',0x00,0x00,0x01,0x00,'S',0x08,0x00};
BSTR bstrng = ::SysAllocStringByteLen(str,sizeof(str));
char* data = _com_util::ConvertBSTRToString(bstrng);
printf("4th element in str:%d ",str[3]);
printf("4th element in :%d ",data[3]);
SysFreeString(bstrng);// deallocates the memory and kills the object
bstrng = NULL; // varaible is initialised to null
}
the output i get is :
4th element in str:1
4th element in str:8
If we dont count the Nulls, the 4th character is 0x08.
This proves that the BSTR is not properly created and it skipped the NULLs while creating the BSTR!!!
amit
|
|
|
|
|
Hello Amit,
I think the problem is you use the lowlevel function SysAllocStringByteLen. This function places an Ansi String into an Unicode BSTR without conversion.
Later ConvertBSTRToString assumes that bstrng contains an unicode string and converts it to ansi. This ist the reaseon that leading zeros are missing.
If you try following
wchar_t str[] = {L'L',0x00,0x00,0x01,0x00,L'S',0x08,0x00};
BSTR bstrng = ::SysAllocStringLen(str,sizeof(str));
it should behave as expected
Welf Wiest
|
|
|
|
|
Hi Welf,
So I understand that using ::SysAllocStringLen() and a Unicode (or wide char) string is better.
But does this mean that there no solution for the same if using ANSI string and ::SysAllocStringByteLen?????
Actually, I recieve the ANSI strings to be converted in BSTR.
I work-around this issue by first converting the ANSI to Unicode by function MultiByteToWideChar() and then using ::SysAllocStringLen().
Does this sounds efficient??
Thanks for your responce
Amit
|
|
|
|
|
Hi Amit,
yes this sounds efficient.
For example I use this code sequence to convert an ANSI STL String to a BSTR in my STL to automation layer
_my_type& operator=(const std::string &Src)
{
DWORD dwLen = Src.length();
CComBSTR bstr(dwLen);
if(dwLen > 0)
if(!MultiByteToWideChar(CP_ACP, 0, Src.c_str(), dwLen, bstr, dwLen))
ThrowFromHRESULT(HRESULT_FROM_WIN32(GetLastError()));
m_vntValue = bstr;
_assign();
return *this;
}
//Simplified Version without STL / ATL
HRESULT toBSTR(const char *szString, BSTR *bstrResult)
{
HRESULT hr = S_OK;
BSTR bstr = 0;
if(bstrResult == 0)
return E_INVALIDARG;
DWORD dwLen = lstrlenA(szString);
bstr = SysAllocStringLen(0, dwLen);
if(bstr == 0)
hr = E_OUTOFMEMORY;
else if(dwLen > 0)
{
if(!MultiByteToWideChar(CP_ACP, 0, szString, dwLen, bstr, dwLen))
hr = HRESULT_FROM_WIN32(GetLastError());
}
if(SUCCEEDED(hr))
*bstrResult = bstr;
else if(bstr != 0)
SysFreeString(bstr);
return hr;
}
This Codes allocates the memory first and then initializes the string by MultiBytToWideChar
Welf
|
|
|
|
|
I have a variant data in VC++ DLL. I want to pass it to Java application through JNI's jstring. How to do it without loosing the embedded Nulls in the variant data.
Thanks in Adv.
Amit
|
|
|
|
|
I have DCOM- server. It good work on the one network (one domain). Need run this server from a different network (other domain) (client in one network, server - in other ).Between this networks - wirewall, and no trust. Have access from firewall between client and server (have ping), but, when client call server, i have error: RPC Server unavailable!
Is It possible: run DCOM server from other domain (without trust between networks) ?
If it's possible, ask me how?
HELP, please...
Thank's...
P.S. Sorry for my bad english...
|
|
|
|
|
Can anyone pls tell how to configure "Network Logon Security" while creating a profile using MAPI.
I need to create the profile without showing the profile creation dialog box (exchange server dialog box).
i used the following code to create a profile.
i could successfully create a profile, but the "Logon Network Security" option is set to "NT Password Authetication" by default.
i want to change it to "None" programmatically using MAPI.
how do i do that ??
please help.
Thank You.
// Initialize MAPI
if (FAILED(hRes = MAPIInitialize(NULL))) {
AfxMessageBox("Could not Initialize MAPI");
return FALSE;
}
// Get an IProfAdmin interface
if (FAILED(hRes = MAPIAdminProfiles(0,&lpProfAdmin))) {
AfxMessageBox("Could not Create Profile. Contact Admin");
return FALSE;
}
// Create a new profile
if (FAILED(hRes = lpProfAdmin->CreateProfile(szProfile,szPassword,NULL,
MAPI_DEFAULT_SERVICES))) {
AfxMessageBox("Could not Create Profile. Contact Admin");
}
Deep George Zachariah
|
|
|
|
|
Hi all,
Can someone please guide me on how can I call a C# COM Object from VC++ 6.0?
Best Regards,
E.A.
|
|
|
|
|
If the lib files were built with the later compilers you will have link problems building with VC6. The latest version of Platform SDK has some libs that will not compile with VC6.
|
|
|
|
|
hi every body
i need help
i want to know the steps to build my own chat room .
iam beginer . its my dream to make chat room
engriri2006
|
|
|
|
|
You may be able to find a canned package in PHP or other web code, but I don't it would be done in COM.
|
|
|
|
|
Perhaps more information on the nuts and bolts of how one actually *writes* this software may be helpful.. I have a step-by-step DCOM tutorial, where I build a simple server which says "Hello, world!" back to the client, may help put some of this in practical perspective...
The tutorials are written as a series of separate articles, called Steps, which cover the major breakpoints in the development of the system.
Step 1 of the tutorial for VC 6 is at
http://www.codeproject.com/com/HelloTutorial1.asp[^]
And Step 1 of the turtorial for Visual C++.NET 2003 is at
http://www.codeproject.com/useritems/HelloTutorial1NET.asp[^]
I tried to write the tutorials in Microsoft-ese, so you can follow along as if you were reading the Scribble tutorial. The VS.NET version is still a work in progress; that's why it's still in "Unedited User Constributions."
Not all the Steps have been written for the VS.NET version yet. But I am working on it!
Stay tuned!
Sincerely Yours,
Brian Hart
Department of Physics and Astronomy
University of California, Irvine
|
|
|
|
|
Hi everyoone,
I made a function that bring any window of any application to top.
But I have a issue with the Microsoft Word application.
When I have many Word application running and I want one of them (specific) on the top of the Z-order, it's allways the same instance of word that come on top. I looked their window handle and there all different.
Example : (doc1) (doc2) (doc3)
If I want doc3, it's doc1 that will prompted on top.
A Work around is that if a press the alt key after the issue operation, the right instance of word come on top of the Z-Order.
Some of functions that I tryed to do that operation:
::SetActiveWindow( oSelectedApp.GetWindow() );<br />
::SetForegroundWindow( oSelectedApp.GetWindow() );<br />
::ShowWindow( oSelectedApp.GetWindow(), SW_SHOW );<br />
::SetWindowPos( oSelectedApp.GetWindow(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW );
I seen this problem only for Microsoft Word application.
Sébastien Nadeau
Software Developper
|
|
|
|
|
Microsoft as the property that many application is launch by the same process.
Only one process "WINWORD.exe" but many instance of word in the Task Manager application list.
|
|
|
|
|
hello
I developed a activeX com component(.ocx) which is having only two property tabs named "set properties" and "extended". I want to add another property page tab in property sheet view. How can i add and use it.
|
|
|
|
|
Simple question: Is it neccessary to release the instance of GraphBuilder everytime you want to render a new file? Or can you merely release the interfaces queried and call RenderFile with the new filename and query the interfaces again?
Thanks.
|
|
|
|
|
Hi,
I'm trying to register a .NET assembly to COM+, and later use these COM+ services again in a .NET client application in a transaction context.
So far, I've been able to get my .NET assemblies into the W2003 server component manager by registering them into the GAC using regsvcs.
Then I exported the components as application proxies, so my client has access to the server where the COM+ components are hosted.
I install them in my client, but when I try to add a reference it says:
"The ActiveX type library was exported from a .NET assembly and can not be added as reference. Add a reference to the .NET assembly instead"
Sorry if this has been asked before, searched for it but nothing showed up. Any help on what Im doing wrong would be greatly appreciated.
Thanks in advance
|
|
|
|
|
Hi everyone!
I need to code a small project which communicates with a Programmable Logic Controller. I was told to do it with a original DLL file (UnCmDrv1.dll) for that. When I used VS 2002 for my project, everything worked fine.
Now that I have updated to VS 2005 I recieve an error while adding a COM reference dll:. The error is following: "Please make sure that the file is accessible, and that it is a valid assembly or COM component."
Is that some sort of bug of VS 2005 or am i doing something wrong. Any help would be appreciated.
Thanks in advance,
Henry
|
|
|
|
|
Hi !
my problem is as follows:
I have a COM module ( COM_A) written in C++ which receives several [IN] parameters and returns [OUT] parameters.
One of the input parameters is defined as [in] VARIANT vArrIn.
One of the output params is defined as [out] VARIANT *dArrOut.
There is no problem when I make the call directly to the respective method !
The problem arises when I try to call COM_A by means of a second COM module (COM_B), which makes use of the COleDdispatchDriver class. When I call COM_A from within COM_B by invoking InvokeHelper, the call fails and the return code says something like : "stub received bad data ...".
I found out that :
1) If there is a normal [in]int parameter AFTER the [in]VARIANT vArrIn, , the call fails.
2) if I invert the order of the params [in]int iVal, [in]VARIANT vArrIn, the calls succeeds.
2)Anyway, it never succeeds when there is an [out] VARIANT *dArrOut after the [in]VARIANT vArrIn parameter.
Why is this happening ? Is it possible to do it this way ?
Can someone please shed a light on this. I tried out many different possibilities, including trying to define the [in]VARIANT as a pointer and to define the [OUT] VARIANT* array as [in,out], it all wouldn't help.
Please help , because I need to find a solution.
Thanks in advance,
Rubi
|
|
|
|
|
Hello Rubi,
Sounds like your problem may be related to marshaling. However, if possible, it would be best if you could send me a scaled down and modified version of your COM server and client code that can re-create the problem.
Please send to : bio_lim_2004@yahoo.com
Best Regards,
Bio.
|
|
|
|
|
Dear Lim,
thank you for trying to help. I caused the problem by not defining the right order of parameters. Vita stated in his posting (one message entry below yours) that "The arguments in the array should be placed from last to first". As soon as I read his posting I understood that I had overlooked this requirement, which for itself is sad enough...! Defining it the proper way fixed my problem.
Thank you again,
Rubi
|
|
|
|
|
Hello Rubi,
No problem and congratulations on discovering the bug. Best of luck to your project.
Regards,
Bio.
|
|
|
|
|