|
Hi,
I am working on a project which involves drag and drop of data between a namespace extension and windows explorer. In this, when a file is dragged from my namespace extension and dropped on explorer I need to know on which folder the file was dropped.
Can someone please help me with this?
Thanks and Regards,
Anil
|
|
|
|
|
Hi,
I have an application in which my application uses COM of some other interfacing application. Because of this interdependency i need to recompile my COM components whenever there is any chnage in the interfacing COM Components. Is there any way to resolve the inter dependency issue. Can i use MIDL (Microsoft Interface Definition Language) to resolve this issue or can i use DCOM.
regards
Sumit
|
|
|
|
|
Can you describe this "interdependency"?
Steve
|
|
|
|
|
Hi Have an application which have COM (compatibility set to Project Compatibility). These COm have interfaces with other COM of different application. When ever there is any change (new function added or deleted, any modification) happens in interface COM i need to recopile again my COM using these new Changed COM of interfacing application.
Is there any way to sort this out. Can i use interface file(IDL) so that if in any case if there is any chnage in interface COM i need to chnage just the interface file not to recopile my COM
Regards
Sumit
|
|
|
|
|
Hi Sumit.
msumit wrote: Is there any way to sort this out
The short answer for this is simply "No, you have to rebuild".
The reason is that if there is an interface change the virtual table for the interface will change as well. If you don't use the correct virtual table you will "jump" to the wrong address when calling an interface function.
On the other hand, one of the corner stones of COM is never to change a distributed interface. You haven't provided enough information about your situation but I assume that the interfaces you are using are under construction and has not been completely specified yet and therefore, I hope, are distributed to a very small, controllable environment. Otherwise you will end up having a situation where you have clients that are incompatible with their servers among your end users and they won't be very happy about that.
Most software that are "kept alive" will usually need some kind of improvement. These improvements could be new functionality through COM interfaces. If this is the case, changing existing interfaces would break the "contract" between the server and its client(s) and the client(s) will not function properly. The symptoms will vary depending on the interface changes.
The correct solution would be to create new interface(s) for the new functionality and also not to make the interfaces too complicated and large. A guideline would be to consider splitting an interface if it contains more than 20 functions. It's a design issue.
Sometimes an original interface require modification. In that case you usually create a new version of the interface appending a number to the interface name and assign a new GUID for it in order not to break the contract between the server and its clients.
Have a look in OLE/COM viewer and you will see interfaces such as IViewObject and IViewObject2. New clients should use the IViewObject2 interface in this case and old clients would continue to use the IViewObject interface like nothing happened even if a server with the new IViewObject2 interface is distributed.
Hope this helps
--
Roger
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
3 steps to reduce (not to avoid completely) interdependencies between COM projects
The basic idea is that interfaces themselves change not every time the implementation modul changes. When you change some code in any source file, the module will be compiled and target binary file wil be linked.
1) Remove project dependencies from external com modules in your solution file.
2) Obtain external interfaces by using #import directive. If your external COM project has .tlb (this is the common case), #import this tlb file, not the target .dll or .exe.
3) (optional. useful for solving cross-dependencies) Collect .idl files of external COM modules in a new project that will be built first during solution build. Exclude those files from build in their native projects.
hallelujah
|
|
|
|
|
hi,
i want to open a popup window of a web page as a simple child window rather than as popup any body can help plz..??
thanx,
sufyan
|
|
|
|
|
Hi,
I am have some problems calling a DLL in embedded Pocket PC. The CoCreateInstance reply a error "Class not registered."
I have already register the DLL in the Pocket PC device and even in the emulator but I still keep getting the same error.
I have a running version for desktop but the same is having problems on embedded. In debug mode, I found that the DLLMain's parameter dwReason is = DLL_PROCESS_DETACH.
Can someone please help me?
Thanks in advance.
|
|
|
|
|
Hello All,
Not to toot my own horn...well, OK...to toot my own horn
You may recall my step-by-step DCOM tutorial for VC6, which I posted at
http://www.codeproject.com/com/HelloTutorial1.asp[^]
The tutorial isn't meant to reveal the underlying theory and gory detail of DCOM itself, just like the Scribble tutorial wasn't exactly meant to tour every nook and cranny of MFC. However, the tutorial shows each step to take to build a very simple DCOM server and client.
People have been asking me to update the tutorial for VS.NET. And, at last, the new tutorial series is in the midst of being written. Check it out at
Step 1: http://www.codeproject.com/useritems/HelloTutorial1NET.asp[^]
The tutorial is written in several "Steps" -- the main parts of the process. Step 1 is linked above, and each Step contains links to every other step.
Do me a favor, and use the rating at the bottom of each step to score that Step, and post to the Steps' message boards with your questions, and also suggestions on how to make a certain Step better etc. I welcome any and all input, and both positive kudos and constructive feedback together are great. Thanks!
Sincerely Yours,
Brian Hart
Department of Physics and Astronomy
University of California, Irvine
-- modified at 4:31 Saturday 31st December, 2005
|
|
|
|
|
I'd like to embed an IE browser control in a window, but suppress the 3D frame and scrollbars.
Using CreateControl() in an MFC project, I've created a WebBrowser2 control, which I then query to get a IWebBrowser2 interface, whose document I query to get an ICustomDoc interface, which I use to call SetUIHandler, passing my own container.
So, basically, I have a container window (subclass of CWnd), which contains the browser control, and then container window implements IDocHostUIHandler in order to implement GetHostInfo() and have it modify some of the flags that control some its appearance (DOCHOSTUIFLAG_NO3DOUTERBORDER and DOCHOSTUIFLAG_SCROLL_NO).
The only mysterious thing is that during runtime, after I call SetUIHandler(), my container window class (the one implementing IDocHostUIHandler) receives only two calls to its QueryInterface, neither of which ask for IDocHostUIHandler! First, it asks for IID_IOleCommandTarget (just after I call SetUIHandler), and later it is asked for {C4D244B0-D43E-11CF-893B-00AA00BDCE1A} which is apparently IDocHostShowUI.
Does this mean I'm going to have to implement these other two interfaces as well?
Could the browser control not be requesting IDocHostUIHandler because of the earlier failures?
Has anyone ever managed to pull off this sort of trick? (Changing embedded (as MFC control CWnd-derivative) browser's appearance)
-- modified at 13:37 Friday 30th December, 2005
|
|
|
|
|
|
Hi, hope someone can help me with this COM access violation on DLL exit...
I have a class (CXmlDom) which wraps MS IXMLDOM COM object to give some XML capability to a DLL. It was based on Tom Archers excellent article "Introducing the XML Document Object Model (DOM)" http://www.codeguru.com/Cpp/misc/misc/article.php/c3707.
The class is used, but not exposed, by dll. The dll has been successfully used in Visual Studio projects in the past.
I tried using the DLL in a new DLL, but now I get access violation on exit.
TestDlg >> NewDll >> OldXmlDll >> CXmlDom
The error occurs (in debug mode) in the destructor of CXmlDom:
_com_ptr_t<_com_IIID<msxml::ixmldomnode,&_guid_2933bf80_7b36_11d2_b20e_00c04f983e60> >::operator=(MSXML::IXMLDOMNode * 0x00000000) line 216 + 3 bytes
_com_ptr_t<_com_IIID<msxml::ixmldomnode,&_guid_2933bf80_7b36_11d2_b20e_00c04f983e60> >::operator=(int 0) line 240
CXmlDom::~CXmlDom() line 702
Based on suggestions on the web, I tried setting the smart pointers IXMLDOMNodePtr and IXMLDOMDocumentPtr to null in ~CXmlDom()
(I had assumed they took care of themselves, being smart).
However, this still gives me access violation on exit, in "pOldInterface->Release();" line 216 of COMIP.h (when it is saving interface)
I am guessing my inexperience with COM and DLLs are leading me to access stuff that has already been destroyed, perhaps due to the use of "nested" dlls.
I tried to use release and detach on smartpointers, but I still get access violations.
Any advice on how to use / unload / release the IXMLDOM COM object in DLLs would be appreciated
(I’m wondering if the COMplicated smart pointers are too smart for me – should never have tried to combine with DLLs )
Thanks
Jens Winslow
|
|
|
|
|
Make sure CoUnitialize() isn't being called before all your smart pointers go out of scope.
|
|
|
|
|
Thanks - I am not calling counitialize deliberetly, but I am guessing it is called indirectly when dll's exit / destructors called. leaves me with problem of how to stop it happening - perhaps forcing order of dll "unload" - anyone have a clue how to do that?
thanks any way - at least it gives me something to work with
Jens
|
|
|
|
|
|
Thanks Sohail - an interesting article linked on your blog
seems to be exactly my problem...but I found the solution unclear.
Sounds like I need a "pre destruct" function to call in first dll, to set the smart pointers to null (as I tried, but failed to do during destruction), then call this function before 2nd calling dll starts its destruction. Only problem is, what if 1st dll destroys first, then calling it will also fail. Seems either way I might get an access violation unless I can control sequence of dll unload.
Hm, perhaps application need to call predestructor, before terminating - except then dll is destryed for other use (not an issue in my case, but not nice - althiugh I guess I am "only" clearing non-global smart pointers, so I guess that is ok...but ugly)
<br />
App >> Dll2 >> Dll1(with smartptrs)<br />
|______>Dll2.predestoy<br />
...........|___>Dll1.predestroy<br />
Any suggestions are welcome
Jens
(Sometimes I miss the old C "you allocate it, you deallocate it" days. Sure, we made mistakes, but atleast we knew what was happening.)
PS edited to get my code picture looking right, had to add "." as spaces were stripped - what kind of code view strips spaces and indentation anyway?
-- modified at 15:51 Thursday 5th January, 2006
|
|
|
|
|
Hey this is my simple soluction, can u try this and
tell me whether it is solved or not...
In the main termination of your application:-
you can do one of the following
CYourClass::ExitInstance()
{
HANDLE h1 = GetModuleHandle("dll1.dll")
HANDLE h2 = GetModuleHandle("dll2.dll")
Now you got wto handles you can free those libraries in
the order you specified as
FreeLibrary(h1);
FreeLibrary(h2);
or
FreeLibrary(h2);
FreeLibrary(h1);
}
mithun
|
|
|
|
|
That is a great idea, just what I was trying to do.
I can't believe it did not remember how to do it - I was considering writing my own callable exit functions in dlls to null the smart pointers so I would be independent of DLL unload order. I won't have a chance to try for a bit, but when I try I will post back.
Thanks Mithun
Jens
-- modified at 12:13 Friday 13th January, 2006
|
|
|
|
|
Hi ,
I have developed the com addin for outlook 2003 . I am creating the toolbar in all the folders. I am loading toolbar when we open the mail item. It's working fine loading the toolbar but when i receive the mail item with RichText format and INternationalisation option Set to Chinese Traditional Big5. When i open such mail item the toolbar doesnot loads. I am Getting problem adding the Control for editing the mail and Setting the font size. When i remove these controls the toolbar is loaded smoothly. I wam Attaching the code for your help in code snippet.
This code works but when you remove the comments for Edit This Mail and Font Size it does not wiork. I think when
the user receives the mail with RichText Format and INternation option set Chinese Traditional Big5 we dont get the
controls in standard toolbar itself , so that we cannot add those control so is there anyway to predict which type of mail is this or check if the mail is Ruch Text Edit or Internation Option Set to Chinese Traditional Big5.
// TODO: Add your implementation code here
CComQIPtr <outlook::_inspector> spInspector(OlInsp);
CComPtr <office::_commandbars> spCommandBars;
CComPtr <office::commandbar> spNewBar;
CComPtr <office::commandbar> spNewMenuBar;
CComPtr <office::commandbarcontrols> spBarControls;
CComPtr <office::commandbarcontrols> spMenuBarControls;
CComPtr <office::commandbarcontrols> spDropDownControls;
CComPtr <office::commandbarcontrols> spDropDownControls1;
CComPtr <office::commandbarcontrol> spCmdControl;
CComPtr <office::commandbarcontrol> control;
CComQIPtr <office::_commandbarbutton> spCmdButton(spCmdControl);
CComQIPtr <office::commandbarpopup> spCmdPopup(spCmdControl);
HRESULT hr;
spInspector->get_CommandBars(&spCommandBars);
spBars=spCommandBars;
hr=spCommandBars->get_Item(CComVariant(Name),&spNewBar);
if (SUCCEEDED(hr))
return hr;
IDispatch *TempItem;
CComPtr<outlook::_mailitem> CurrItem;
Outlook::OlObjectClass olmyClass;
spInspector->get_CurrentItem(&TempItem);
CurrItem=reinterpret_cast<outlook::_mailitem*>(TempItem);
hr=CurrItem->get_Class(&olmyClass);
char *str=new char[4];
itoa(olmyClass,str,5);
::MessageBox(NULL,str,"Outlook",MB_OK);
CComVariant vName(Name);
CComVariant vPos(1);
CComVariant vTemp(VARIANT_TRUE);
CComVariant vEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
spNewBar=spCommandBars->Add(vName, vPos, vEmpty, vTemp);
spNewBar->Visible=true;
spBarControls = spNewBar->GetControls();
ATLASSERT(spBarControls);
//Declare Variant Types
CComVariant vToolBarType(1); //Simple Button
CComVariant vToolBarDropDown(10); //Drop Down Button
CComVariant vShow(VARIANT_TRUE); //True
CComVariant vType(Office::msoButtonIconAndCaption); //Style for Button
//Previous Mail
control=spCommandBars->FindControl(vToolBarType,CComVariant(359) );
CComQIPtr <office::_commandbarbutton>spCmdPrevMail(control->Copy(CComVariant(spNewBar)));
spCmdPrevMail->PutStyle(Office::msoButtonIconAndCaption);
spCmdPrevMail->Caption= "Previous Mail";
//Next Mail
control=spCommandBars->FindControl(vToolBarType,CComVariant (360));
CComQIPtr < Office::_CommandBarButton>spCmdNextMail(control->Copy(CComVariant(spNewBar)));
spCmdNextMail->PutStyle(Office::msoButtonIconAndCaption);
spCmdNextMail->PutFaceId(360);
spCmdNextMail->Caption="Next Mail";
//Edit This Mail
/* control=spCommandBars->FindControl(vEmpty,CComVariant (5604),vEmpty,vEmpty);
CComQIPtr < Office::_CommandBarButton> spCmdEditMail(control->Copy(CComVariant(spNewBar)));
spCmdEditMail->PutStyle(Office::msoButtonIconAndCaption);
spCmdEditMail->PutFaceId(31);
spCmdEditMail->Caption="Edit This Mail";
::MessageBox(NULL,"here 2","",0);
//Font Size
control=spCommandBars->FindControl(vEmpty,CComVariant (5571),vEmpty,vEmpty);
CComQIPtr < Office::_CommandBarButton> spCmdFontSize(control->Copy(CComVariant(spNewBar)));
spCmdFontSize->PutStyle(Office::msoButtonIconAndCaption);
spCmdFontSize->Caption="Font Size";
::MessageBox(NULL,"here 3","",0);
*/
//Copy
control=spBarControls->Add(CComVariant(1),CComVariant(19));
CComQIPtr < Office::_CommandBarButton> spCmdCopy(control->Move(CComVariant(spNewBar)));
spCmdCopy->PutStyle(Office::msoButtonIconAndCaption);
spCmdCopy->Caption="Copy";
spButton1->put_Tag(L"InboxLv1");
SaveCloseInbox::DispEventAdvise((IDispatch*)spButton1);
*pNewBar=spNewBar;
return S_OK;
I look forward to your reply,
Regards
Ganesh
hi
|
|
|
|
|
I have a COM inproc dll and have written a mc file containing my own custom HResults. When my component throws the HRESULT, I am checking for its value in my MFC Client by use of FormatMessage.
The HR value returned matches with the message ID but the message string comes out to a garbage value.
Has anyone written custom HRs in component and displayed the message in the MFC client before? If yes, how does it work?
Thanks for the help!
-Mandira
|
|
|
|
|
Hi,
I am trying to use Windows Media Player library "WMSServerTypeLib.dll" as an interop. I created the "WMSServerLib.dll" type library and registered using regasm.
When I try to create the object,it throws the following com exception error:
COM object with CLSID {845FB959-4279-11D2-BF23-00805FBE84A6} is either not valid or not registered.
WMSServerClass Server = new WMSServerClass();
I am able to see all the Interfaces in the object viewer
rgds
Jaffar
-- modified at 6:22 Tuesday 27th December, 2005
|
|
|
|
|
When you create an interop Dll you do not register it with regasm. An interop Dll is not a COM Dll, it is a mapping between C# and the actual COM object. You may have replaced the media player COM object with your interop Dll.
|
|
|
|
|
Hi all,
i ahve downloaded a WMI application to get WMI data from maremote computer .
i have taken a win32 console application and included a source file an dto that source file i have included the code
#include "Windows.h"
#include "comdef.h"
//#include "Wbemidl.h"
#define _WIN32_DCOM
#include <iostream>
using namespace std;
#include <comdef.h>
#include <wbemidl.h>
# pragma comment(lib, "wbemuuid.lib")
int main(int argc, char **argv)
{
HRESULT hres;
// Step 1: --------------------------------------------------
// Initialize COM. ------------------------------------------
hres = CoInitializeEx(0, COINIT_MULTITHREADED);
if (FAILED(hres))
{
cout << "Failed to initialize COM library. Error code = 0x"
<< hex << hres << endl;
return 1; // Program has failed.
}
// Step 2: --------------------------------------------------
// Set general COM security levels --------------------------
// Note: If you are using Windows 2000, you need to specify -
// the default authentication credentials for a user by using
// a SOLE_AUTHENTICATION_LIST structure in the pAuthList ----
// parameter of CoInitializeSecurity ------------------------
hres = CoInitializeSecurity(
NULL,
-1, // COM authentication
NULL, // Authentication services
NULL, // Reserved
RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication
RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation
NULL, // Authentication info
EOAC_NONE, // Additional capabilities
NULL // Reserved
);
if (FAILED(hres))
{
cout << "Failed to initialize security. Error code = 0x"
<< hex << hres << endl;
CoUninitialize();
return 1; // Program has failed.
}
// Step 3: ---------------------------------------------------
// Obtain the initial locator to WMI -------------------------
IWbemLocator *pLoc = NULL;
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.
}
// Step 4: -----------------------------------------------------
// Connect to WMI through the IWbemLocator::ConnectServer method
IWbemServices *pSvc = NULL;
// Connect to the root\cimv2 namespace with
// the current user and obtain pointer pSvc
// to make IWbemServices calls.
hres = pLoc->ConnectServer(
_bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace
NULL, // User name. NULL = current user
NULL, // User password. NULL = current
0, // Locale. NULL indicates current
NULL, // Security flags.
0, // Authority (e.g. Kerberos)
0, // Context object
&pSvc // pointer to IWbemServices proxy
);
if (FAILED(hres))
{
cout << "Could not connect. Error code = 0x"
<< hex << hres << endl;
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}
cout << "Connected to ROOT\\CIMV2 WMI namespace" << endl;
// Step 5: --------------------------------------------------
// Set security levels on the proxy -------------------------
hres = CoSetProxyBlanket(
pSvc, // Indicates the proxy to set
RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx
RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx
NULL, // Server principal name
RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx
RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx
NULL, // client identity
EOAC_NONE // proxy capabilities
);
if (FAILED(hres))
{
cout << "Could not set proxy blanket. Error code = 0x"
<< hex << hres << endl;
pSvc->Release();
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}
// Step 6: --------------------------------------------------
// Use the IWbemServices pointer to make requests of WMI ----
// For example, get the name of the operating system
IEnumWbemClassObject* pEnumerator = NULL;
hres = pSvc->ExecQuery(
bstr_t("WQL"),
bstr_t("SELECT * FROM Win32_OperatingSystem"),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);
if (FAILED(hres))
{
cout << "Query for operating system name failed."
<< " Error code = 0x"
<< hex << hres << endl;
pSvc->Release();
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}
// Step 7: -------------------------------------------------
// Get the data from the query in step 6 -------------------
IWbemClassObject *pclsObj;
ULONG uReturn = 0;
while (pEnumerator)
{
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1,
&pclsObj, &uReturn);
if(0 == uReturn)
{
break;
}
VARIANT vtProp;
VariantInit(&vtProp);
// Get the value of the Name property
hr = pclsObj->Get(L"Name", 0, &vtProp, 0, 0);
wcout << " OS Name : " << vtProp.bstrVal << endl;
VariantClear(&vtProp);
}
// Cleanup
// ========
pSvc->Release();
pLoc->Release();
pEnumerator->Release();
pclsObj->Release();
CoUninitialize();
return 0; // Program successfully completed.
}
but when iam compiling iam getting the following error
fatal error C1083: Cannot open include file: 'Wbemidl.h': No such file or directory
so can u please me regarding this
abhi
|
|
|
|
|
Hi
I gave developed the com addin for outlook 2003. I am attaching toolbar in inbox second level. If the username is in Chinese Traditional Charset then it doesn't work. I mean the toolbars does not get attached.
I have written code and on reveiewing i think something goes wrong here..
CComPtr<outlook::recipient>CurrUser;
BSTR username;
char* strName=new char[50];
mysession->get_CurrentUser(&CurrUser);
CurrUser->get_Name(&username);
strcpy(strName,"\nCreated By: ");
strName=strcat(strName,_com_util::ConvertBSTRToString(username));
strcpy(m_username,strName);
delete strName;
strName=0;
...
This is not unicode strings char* and if username is Chinese Traditional charset code is imncorrect.
this coment was given by one of my senior friend.
Looking forward for reply,
Cheers
Ganesh
hi
|
|
|
|
|
Hello,
I am trying to play video inside a panel.
The problem is that i can't get a window handle for the planel and here is the code that i am wriiting:
pWindow->put_Owner (this->panel1->Handle);
[Error C2664]: 'IVideoWindow::put_Owner' : cannot convert parameter 1 from 'System::IntPtr' to 'OAHWND'
How can i fix this problem. My end goal is just to play the file in the panel not in a pop up window!!
Thanks
|
|
|
|
|