|
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.
|
|
|
|
|
Take a look into MSDN's "Passing Parameters" topic (or search for these words). From there:
typedef struct FARSTRUCT tagDISPPARAMS{
VARIANTARG FAR* rgvarg;// Array of arguments.
DISPID FAR* rgdispidNamedArgs; // Dispatch IDs of named arguments.
unsigned int cArgs;// Number of arguments.
unsigned int cNamedArgs; // Number of named arguments.
} DISPPARAMS;
The arguments are passed in the array rgvarg[ ], with the number of arguments passed in cArgs. The arguments in the array should be placed from last to first, so rgvarg[0] has the last argument and rgvarg[cArgs -1] has the first argument. The method or property may change the values of elements within the array rgvarg, but only if it has set the VT_BYREF flag. Otherwise, consider the elements as read-only.
With best wishes,
Vita
-- modified at 10:36 Friday 11th November, 2005
|
|
|
|
|
Dear Vita ,
thank you so much for helping me solve the problem. The reason was in fact the order by which the args were defined , I had overlooked the requirement that , as you stated : "The arguments in the array should be placed from last to first". After having fixed this , everything works out fine now .
Thank you,
Rubi
|
|
|
|
|
Hi all,
I have a really difficult problem.
I have an MFC application that hosts scripts via IActveScript engine. Inside the script I have created a COM object that exposes some events. The very same object is correctly used in a regular vbs scipt host by WSH:
<br />
Dim obj<br />
Set obj = CreateObject ("cnitfc.myobj")<br />
wscript.ConnectObject obj, "myobj_"<br />
<br />
Sub myobj_Event (nParam)<br />
msgbox "event fired"<br />
End Sub<br />
and myobj_Eventis is invoked when myobj fires "Event" event.
How to implement the very same "ConnectObject" method that is built-in into wscript object?
Thanks a lot in advance.
Regards,
Andrea
|
|
|
|
|
Now I'm trying to use IFolderCollection:
struct __declspec(uuid("c7c3f5a3-88a3-11d0-abcb-00a0c90fffc0"))
IFolderCollection : IDispatch
{
...
virtual HRESULT __stdcall get_Item (
VARIANT Key,
struct IFolder * * ppfolder ) = 0;
...
}
In my code, I have got an interface of IFolderCollection. And I want to enumerate the sub folders:
LONG nCount = qSubFolders->GetCount();
...
//
for (INT nLoop = 1; nLoop <= nCount; nLoop++)
{
CComVariant vtKey(nLoop);
vtKey.ChangeType(??????????); //Which type is "Key" type?
CComPtr<IFolder> qFolder;
qSubFolders->get_Item(vtKey, &qFolder); //Always fail!
if (qFolder == NULL)
{
}
...
In VB, I can write "Curfolder = Subfolders.Item(1)", but what about C++?
-- modified at 23:27 Sunday 6th November, 2005
|
|
|
|
|
Do you have access to the get_Item function? It is the only way to know the type. If I correctly undestand
<br />
set Curfolder = Subfolders.Item(1)<br />
works, so it should work in C++ as well, with vtKey.ChangeType (VT_I2), vtKey.ChangeType (VT_I4), vtKey.ChangeType (VT_R4), or vtKey.ChangeType (VT_R8).
You should also get the return code or some error info.
Regards,
Andrea
|
|
|
|
|
Thanks a lot.
I'm sorry that I made a mistake.
I haven't used VB for 2 years, so actually
set Curfolder = Subfolders.Item(1) is only in my memory, it can NOT work.
I found I could only visit this collection via "for each" in VB:
<br />
For Each folderCur In subFolders<br />
Debug.Print folderCur.Path<br />
Next<br />
So what should I do in C++?
Shall I use IFolderCollection::get__NewEnum(IUnknown * * ppenum) method?
How to?
Thanks.
-- modified at 7:54 Monday 7th November, 2005
|
|
|
|
|