Search Results

Search found 46 results on 2 pages for 'iunknown'.

Page 1/2 | 1 2  | Next Page >

  • COM IUnknown and do I need a pointer to it first before calling CoGetClassObject?

    - by Tony
    In COM, when you want to create an instance of some COM Server object, do you first need to get a pointer to it's IUnknown interface and only then create a class object using CoGetClassObject? As far as I understand it, IUnknown is used to manage object lifetimes, so from my understanding, whatever object the client wants to create, one needs a pointer to it's IUnknown interface implementation first. Sound correct? If not, can anyone tell me how it works?

    Read the article

  • Is there a COM object that just implements IUnknown I can use?

    - by Matt
    For an asynchronous Windows API, I can provide an IUnknown state parameter to associate calls to the API with calls from the callback. It's my understanding that COM guarantees that two IUnknown pointers to the same object will be of the same value. Thus, if I only want to associate API calls with callbacks, IUnknown should be all I need, by comparing the values of the pointers. Is there a stock implementation of IUnknown I can use? Of course it would be trivial to implement myself, but for such a base component of COM, I'm wondering if Windows or ATL provides one I should use instead. Thanks, --Matt

    Read the article

  • Hook IDispatch v-table in C++

    - by monoceres
    I'm trying to modify the behavior of an IDispatch interface already present in the system. To do this my plan was to hook into the objects v-table during runtime and modify the pointers so it points to a custom hook method instead. If I can get this to work I can add new methods and properties to already existing objects. Nice. First I tried hooking into the v-table for IUnknown (from which IDispatch inherits from) and that worked fine. However trying to change entires in IDispatch doesn't work at all. Nothing happens at all, the code works just as it did without the hook. Here's the code, it's very simple so it shouldn't be any problems to understand #include <iostream> #include <windows.h> #include <Objbase.h> #pragma comment (lib,"Ole32.lib") using namespace std; HRESULT __stdcall typecount(IDispatch *self,UINT*u) { cout << "hook" << endl; *u=1; return S_OK; } int main() { CoInitialize(NULL); // Get clsid from name CLSID clsid; CLSIDFromProgID(L"shell.application",&clsid); // Create instance IDispatch *obj=NULL; CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(IDispatch),(void**)&obj); // Get vtable and offset in vtable for idispatch void* iunknown_vtable= (void*)*((unsigned int*)obj); // There are three entries in IUnknown, therefore add 12 to go to IDispatch void* idispatch_vtable = (void*)(((unsigned int)iunknown_vtable)+12); // Get pointer of first emtry in IDispatch vtable (GetTypeInfoCount) unsigned int* v1 = (unsigned int*)iunknown_vtable; // Change memory permissions so address can be overwritten DWORD old; VirtualProtect(v1,4,PAGE_EXECUTE_READWRITE,&old); // Override v-table pointer *v1 = (unsigned int) typecount; // Try calling GetTypeInfo count, should now be hooked. But isn't works as usual UINT num=0; obj->GetTypeInfoCount(&num); /* HRESULT hresult; OLECHAR FAR* szMember = (OLECHAR*)L"MinimizeAll"; DISPID dispid; DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; hresult = obj->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_SYSTEM_DEFAULT, &dispid) ; hresult = obj->Invoke(dispid,IID_NULL,LOCALE_SYSTEM_DEFAULT,DISPATCH_METHOD,&dispparamsNoArgs, NULL, NULL, NULL); */ } Thanks in advance!

    Read the article

  • Using mem_fun_ref with boost::shared_ptr

    - by BlueRaja
    Following the advice of this page, I'm trying to get shared_ptr to call IUnknown::Release() instead of delete: IDirectDrawSurface* dds; ... //Allocate dds return shared_ptr<IDirectDrawSurface>(dds, mem_fun_ref(&IUnknown::Release)); error C2784: 'std::const_mem_fun1_ref_t<_Result,_Ty,_Arg std::mem_fun_ref(Result (_thiscall _Ty::* )(_Arg) const)' : could not deduce template argument for 'Result (_thiscall _Ty::* )(Arg) const' from 'ULONG (_cdecl IUnknown::* )(void)' error C2784: 'std::const_mem_fun_ref_t<_Result,_Ty std::mem_fun_ref(Result (_thiscall _Ty::* )(void) const)' : could not deduce template argument for 'Result (_thiscall _Ty::* )(void) const' from 'ULONG (__cdecl IUnknown::* )(void)' error C2784: 'std::mem_fun1_ref_t<_Result,_Ty,_Arg std::mem_fun_ref(Result (_thiscall _Ty::* )(_Arg))' : could not deduce template argument for 'Result (_thiscall _Ty::* )(Arg)' from 'ULONG (_cdecl IUnknown::* )(void)' error C2784: 'std::mem_fun_ref_t<_Result,_Ty std::mem_fun_ref(Result (_thiscall _Ty::* )(void))' : could not deduce template argument for 'Result (_thiscall _Ty::* )(void)' from 'ULONG (__cdecl IUnknown::* )(void)' error C2661: 'boost::shared_ptr::shared_ptr' : no overloaded function takes 2 arguments I have no idea what to make of this. My limited template/functor knowledge led me to try typedef ULONG (IUnknown::*releaseSignature)(void); shared_ptr<IDirectDrawSurface>(dds, mem_fun_ref(static_cast<releaseSignature>(&IUnknown::Release))); But to no avail. Any ideas?

    Read the article

  • "Win32 exception occurred releasing IUnknown at..." error using Pylons and WMI

    - by Anders
    Hi all, Im using Pylons in combination with WMI module to do some basic system monitoring of a couple of machines, for POSIX based systems everything is simple - for Windows - not so much. Doing a request to the Pylons server to get current CPU, however it's not working well, or atleast with the WMI module. First i simply did (something) this: c = wmi.WMI() for cpu in c.Win32_Processor(): value = cpu.LoadPercentage However, that gave me an error when accessing this module via Pylons (GET http://ip:port/cpu): raise x_wmi_uninitialised_thread ("WMI returned a syntax error: you're probably running inside a thread without first calling pythoncom.CoInitialize[Ex]") x_wmi_uninitialised_thread: <x_wmi: WMI returned a syntax error: you're probably running inside a thread without first calling pythoncom.CoInitialize[Ex] (no underlying exception)> Looking at http://timgolden.me.uk/python/wmi/tutorial.html, i wrapped the code accordingly to the example under the topic "CoInitialize & CoUninitialize", which makes the code work, but it keeps throwing "Win32 exception occurred releasing IUnknown at..." And then looking at http://mail.python.org/pipermail/python-win32/2007-August/006237.html and the follow up post, trying to follow that - however pythoncom._GetInterfaceCount() is always 20. Im guessing this is someway related to Pylons spawning worker threads and crap like that, however im kinda lost here, advice would be nice. Thanks in advance, Anders

    Read the article

  • Should I post my PDF library for SEO? [closed]

    - by Iunknown
    Possible Duplicate: Do search engines crawl PDFs and if so are there any rules to follow when making them When a Sales call comes in, the caller often says something like: 'I searched for 3 days before finding your product and it's exactly what I need!' That's telling me that I need some SEO work. We redid our website and streamlined it which removed many of our 'How-To' documents. Since those PDF documents contain words that people might search for, I was wondering if I could add a 'Complete library' link to the bottom of a page that will load up the entire PDF library. Would that help my ranking?

    Read the article

  • E2251 Ambiguous overloaded call to ....

    - by Eric M
    I inherited some Delphi components/code that currently compiles with C++ Builder 2007. I'm simply now trying to compile the components with C++ Builder RAD XE. I don't know Delphi (object pascal). Here are the versions of the 'Supports' functions that appear to be in conflict. Is there a compiler switch I can use to make RAD XE backward compatible? Or is there something I can do to these function calls to correct the ambiguous nature? {$IFNDEF DELPHI5} procedure FreeAndNil(var Obj); var Temp: TObject; begin Temp := TObject(Obj); Pointer(Obj) := nil; Temp.Free; end; function Supports(const Instance: IUnknown; const Intf: TGUID; out Inst): Boolean; overload; begin Result := (Instance <> nil) and (Instance.QueryInterface(Intf, Inst) = 0); end; function Supports(Instance: TObject; const Intf: TGUID; out Inst): Boolean; overload; var Unk: IUnknown; begin Result := (Instance <> nil) and Instance.GetInterface(IUnknown, Unk) and Supports(Unk, Intf, Inst); end; {$ENDIF} {$IFNDEF DELPHI6} function Supports(const Instance: TObject; const IID: TGUID): Boolean; var Temp: IUnknown; begin Result := Supports(Instance, IID, Temp); end; {$ENDIF}

    Read the article

  • Multiple Silverlight Unit Test Projects in Solution

    - by IUnknown
    I am building out a number of Silverlight 4.0 libraries that are part of the same solution. I like to break them into separate projects and have a Unit Test project for each: SolutionX -LibraryProject1 ---Class1.cs ---Class2.cs -LibraryProject1.Test ---Tests1.cs ---Tests2.cs -LibraryProject2 ---Class1.cs ---Class2.cs ---CLass3.cs -LibraryProject2.Test ---Tests1.cs ---Tests2.cs ---Tests3.cs -LibraryProject3 ---Class1.cs -LibraryProject3.Test ---Tests1.cs This works great when using VS regular test projects and infrastructure because I can create and execute list of test that are aggregated from each Test project. But with the Silverlight Unit Test Framework since the Silverlight Unit Test Project must be the "start up project" I cannot figure how to run a collection of tests from each test project in one go. I have to run each separately then switch the starting project each time. I would prefer to avoid create complex build scripts or build definitions - is there a way to run all the tests at once? -Thanks

    Read the article

  • Getting the CVE ID Property of an update from WSUS API via Powershell

    - by thebitsandthebytes
    I am writing a script in Powershell to get the update information from each computer and correlate the information with another System which identifies updates by CVE ID. I have discovered that there is a "CVEIDs" property for an update in WSUS, which is documented in MSDN, but I have no idea how to access the property. Retrieving the CVE ID from WSUS is the key to this script, so I am hoping someone out there can help! Here is the property that I am having difficulty accessing: IUpdate2::CveIDs Property - http://msdn.microsoft.com/en-us/library/aa386102(VS.85).aspx According to this, the IUnknown::QueryInterface method is needed to interface IUpdate2 -  "http://msdn.microsoft.com/en-us/library/ee917057(PROT.10).aspx" "An IUpdate instance can be retrieved by calling the IUpdateCollection::Item (opnum 8) (section 3.22.4.1) method.  The client can use the IUnknown::QueryInterface method to then obtain an IUpdate2, IUpdate3, IUpdate4, or IUpdate5 interface. Additionally, if the update is a driver, the client can use the IUnknown::QueryInterface method to obtain an IWindowsDriverUpdate, IWindowsDriverUpdate2, IWindowsDriverUpdate3, IWindowsDriverUpdate4, or IWindowsDriverUpdate5 interface. " Here is a skeleton of my code: [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | Out-Null  if (!$wsus)  {  Returns an object that implements IUpdateServer  $wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer($server, $false, $port)  }  $computerScope = New-Object Microsoft.UpdateServices.Administration.ComputerTargetScope  $updateScope = New-Object Microsoft.UpdateServices.Administration.UpdateScope  $updateScope.UpdateSources = [Microsoft.UpdateServices.Administration.UpdateSources]::MicrosoftUpdate  $wsusMachines = $wsus.GetComputerTargets($computerScope)  foreach machine in QSUS, write the full domain name $wsusMachines | ForEach-Object {  Write-host $.FullDomainName  $updates = $.GetUpdateInstallationInfoPerUpdate($updateScope)  foreach update for each machine, write the update title, installation state and securitybulletin $updates | ForEach-Object {  $update = $wsus.GetUpdate($.UpdateId) # Returns an object that implements Microsoft.UpdateServices.Administration.IUpdate $updateTitle = $update.Title | Write-Host $updateInstallationState = $.UpdateInstallationState | Write-Host $updateSecurityBulletin = $update.SecurityBulletins | Write-Host  $updateCveIds = $update.CveIDs # ERROR: Property 'CveIDs' belongs to IUpdate2, not IUpdate  }  }

    Read the article

  • INetCfgComponent::RaisePropertyUi arguments

    - by Soo Wei Tan
    I'm trying to do some COM interop and attempting to invoke the INetCfgComponent::RaisePropertyUi method. I've gotten to the point where I can enumerate devices and get a valid INetCfgComponent for the adapter that I want to display the UI for. However, I'm a COM newbie (let alone COM interop) so I have no idea what the third argument in RaisePropertyUi() is meant to be. I've tried passing in the INetCfgComponent object that I have, but that just results in a InvalidCastException. MSDN has the following to say about the argument: Pointer to the IUnknown interface. RaisePropertyUi retrieves from IUnknown the interface of the context in which to display a network component's property sheet. RaisePropertyUi uses this interface to restrict the display of the property sheet to the context of a connection.

    Read the article

  • How can i do this using a Python Regex?

    - by uberjumper
    I am trying to properly extract methods definitions that are generated by comtypes for Com Interfaces using a regex. Furthermore some of them are blank which causes even more problems for me. Basically i have this: IXMLSerializerAlt._methods_ = [ COMMETHOD([helpstring(u'Loads an object from an XML string.')], HRESULT, 'LoadFromString', ( ['in'], BSTR, 'XML' ), ( ['in'], BSTR, 'TypeName' ), ( ['in'], BSTR, 'TypeNamespaceURI' ), ( ['retval', 'out'], POINTER(POINTER(IUnknown)), 'obj' )), ] class EnvironmentManager(CoClass): u'Singleton object that manages different environments (collections of configuration information).' _reg_clsid_ = GUID('{8A626D49-5F5E-47D9-9463-0B802E9C4167}') _idlflags_ = [] _typelib_path_ = typelib_path _reg_typelib_ = ('{5E1F7BC3-67C5-4AEE-8EC6-C4B73AAC42ED}', 1, 0) INumberFormat._methods_ = [ ] I want to extract both the IXMLSerializerAlt and INumberFormat methods definitions however i cant figure out a proper regex. E.g. for IXMLSerializer i want to extract this: IXMLSerializerAlt._methods_ = [ COMMETHOD([helpstring(u'Loads an object from an XML string.')], HRESULT, 'LoadFromString', ( ['in'], BSTR, 'XML' ), ( ['in'], BSTR, 'TypeName' ), ( ['in'], BSTR, 'TypeNamespaceURI' ), ( ['retval', 'out'], POINTER(POINTER(IUnknown)), 'obj' )), ] This regex in my mind this should work: ^\w+\._methods_\s=\s\[$ (^.+$)* ^]$ Im checking my regex's using kodos however i cannot figure out a way to make this work.

    Read the article

  • Type of Blobs

    - by kaleidoscope
    With the release of Windows Azure November 2009 CTP, now we have two types of blobs. Block Blob - This blob type is in place since PDC 2008 and is optimized for streaming workloads. [Max Size allowed : 200GB] Page Blob - With November 2009 CTP release, a new blob type is added which is optimized for random read / writes called Page Blob. [Max Size allowed : 1TB] More details can be found at: http://geekswithblogs.net/IUnknown/archive/2009/11/16/azure-november-ctp-announced.aspx Amit, S

    Read the article

  • HELP: MS Virtual Disk Service to Access Volumes and Discs on Local Machine.

    - by Jibran Ahmed
    Hi, here it is my code through which I am successfully initialize the VDS service and get the Packs but When I call QueryVolumes on IVdsPack Object, I am able to get IEnumVdsObjects but unable to get IUnknown* array through IEnumVdsObject::Next method, it reutrns S_FALSE with IUnkown* = NULL. So this IUnknown* cant be used to QueryInterface for IVdsVolume Below is my code HRESULT hResult; IVdsService* pService = NULL; IVdsServiceLoader *pLoader = NULL; //Launch the VDS Service hResult = CoInitialize(NULL); if( SUCCEEDED(hResult) ) { hResult = CoCreateInstance( CLSID_VdsLoader, NULL, CLSCTX_LOCAL_SERVER, IID_IVdsServiceLoader, (void**) &pLoader ); //if succeeded load VDS on local machine if( SUCCEEDED(hResult) ) pLoader->LoadService(NULL, &pService); //Done with Loader now release VDS Loader interface _SafeRelease(pLoader); if( SUCCEEDED(hResult) ) { hResult = pService->WaitForServiceReady(); if ( SUCCEEDED(hResult) ) { AfxMessageBox(L"VDS Service Loaded"); IEnumVdsObject* pEnumVdsObject = NULL; hResult = pService->QueryProviders(VDS_QUERY_SOFTWARE_PROVIDERS, &pEnumVdsObject); IUnknown* ppObjUnk ; IVdsSwProvider* pVdsSwProvider = NULL; IVdsPack* pVdsPack = NULL; IVdsVolume* pVdsVolume = NULL; ULONG ulFetched = 0; hResult = E_INVALIDARG; while(!SUCCEEDED(hResult)) { hResult = pEnumVdsObject->Next(1, &ppObjUnk, &ulFetched); hResult = ppObjUnk->QueryInterface(IID_IVdsSwProvider, (void**)&pVdsSwProvider); if(!SUCCEEDED(hResult)) _SafeRelease(ppObjUnk); } _SafeRelease(pEnumVdsObject); _SafeRelease(ppObjUnk); hResult = pVdsSwProvider->QueryPacks(&pEnumVdsObject); hResult = E_INVALIDARG; while(!SUCCEEDED(hResult)) { hResult = pEnumVdsObject->Next(1, &ppObjUnk, &ulFetched); hResult = ppObjUnk->QueryInterface(IID_IVdsPack, (void**)&pVdsPack); if(!SUCCEEDED(hResult)) _SafeRelease(ppObjUnk); } _SafeRelease(pEnumVdsObject); _SafeRelease(ppObjUnk); hResult = pVdsPack->QueryVolumes(&pEnumVdsObject); pEnumVdsObject->Reset(); hResult = E_INVALIDARG; ulFetched = 0; BOOL bDone = FALSE; while(!SUCCEEDED(hResult)) { hResult = pEnumVdsObject->Next(1, &ppObjUnk, &ulFetched); //hResult = ppObjUnk->QueryInterface(IID_IVdsVolume, (void**)&pVdsVolume); if(!SUCCEEDED(hResult)) _SafeRelease(ppObjUnk); } _SafeRelease(pEnumVdsObject); _SafeRelease(ppObjUnk); _SafeRelease(pVdsPack); _SafeRelease(pVdsSwProvider); // hResult = pVdsVolume-AddAccessPath(TEXT("G:\")); if(SUCCEEDED(hResult)) AfxMessageBox(L"Add Access Path Successfully"); else AfxMessageBox(L"Unable to Add access path"); //UUID of IVdsVolumeMF {EE2D5DED-6236-4169-931D-B9778CE03DC6} static const GUID GUID_IVdsVolumeMF = {0xEE2D5DED, 0x6236, 4169,{0x93, 0x1D, 0xB9, 0x77, 0x8C, 0xE0, 0x3D, 0XC6} }; hResult = pService->GetObject(GUID_IVdsVolumeMF, VDS_OT_VOLUME, &ppObjUnk); if(hResult == VDS_E_OBJECT_NOT_FOUND) AfxMessageBox(L"Object Not found"); if(hResult == VDS_E_INITIALIZED_FAILED) AfxMessageBox(L"Initialization failed"); // pVdsVolume = reinterpret_cast(ppObjUnk); if(SUCCEEDED(hResult)) { // hResult = pVdsVolume-AddAccessPath(TEXT("G:\")); if(SUCCEEDED(hResult)) { IVdsAsync* ppVdsSync; AfxMessageBox(L"Formatting is about to Start......"); // hResult = pVdsVolume-Format(VDS_FST_UDF, TEXT("UDF_FORMAT_TEST"), 2048, TRUE, FALSE, FALSE, &ppVdsSync); if(SUCCEEDED(hResult)) AfxMessageBox(L"Formatting Started......."); else AfxMessageBox(L"Formatting Failed"); } else AfxMessageBox(L"Unable to Add Access Path"); } _SafeRelease(pVdsVolume); } else { AfxMessageBox(L"VDS Service Cannot be Loaded"); } } } _SafeRelease(pService);

    Read the article

  • What is this code?

    - by Aerovistae
    This is from the Evolution of a Programmer "joke", at the "Master Programmer" level. It seems to be C++, but I don't know what all this bloated extra stuff is, nor did any Google searches turn up anything except the joke I took it from. Can anyone tell me more about what I'm reading here? [ uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820) ] library LHello { // bring in the master library importlib("actimp.tlb"); importlib("actexp.tlb"); // bring in my interfaces #include "pshlo.idl" [ uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820) ] cotype THello { interface IHello; interface IPersistFile; }; }; [ exe, uuid(2573F890-CFEE-101A-9A9F-00AA00342820) ] module CHelloLib { // some code related header files importheader(<windows.h>); importheader(<ole2.h>); importheader(<except.hxx>); importheader("pshlo.h"); importheader("shlo.hxx"); importheader("mycls.hxx"); // needed typelibs importlib("actimp.tlb"); importlib("actexp.tlb"); importlib("thlo.tlb"); [ uuid(2573F891-CFEE-101A-9A9F-00AA00342820), aggregatable ] coclass CHello { cotype THello; }; }; #include "ipfix.hxx" extern HANDLE hEvent; class CHello : public CHelloBase { public: IPFIX(CLSID_CHello); CHello(IUnknown *pUnk); ~CHello(); HRESULT __stdcall PrintSz(LPWSTR pwszString); private: static int cObjRef; }; #include <windows.h> #include <ole2.h> #include <stdio.h> #include <stdlib.h> #include "thlo.h" #include "pshlo.h" #include "shlo.hxx" #include "mycls.hxx" int CHello:cObjRef = 0; CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk) { cObjRef++; return; } HRESULT __stdcall CHello::PrintSz(LPWSTR pwszString) { printf("%ws\n", pwszString); return(ResultFromScode(S_OK)); } CHello::~CHello(void) { // when the object count goes to zero, stop the server cObjRef--; if( cObjRef == 0 ) PulseEvent(hEvent); return; } #include <windows.h> #include <ole2.h> #include "pshlo.h" #include "shlo.hxx" #include "mycls.hxx" HANDLE hEvent; int _cdecl main( int argc, char * argv[] ) { ULONG ulRef; DWORD dwRegistration; CHelloCF *pCF = new CHelloCF(); hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); // Initialize the OLE libraries CoInitiali, NULL); // Initialize the OLE libraries CoInitializeEx(NULL, COINIT_MULTITHREADED); CoRegisterClassObject(CLSID_CHello, pCF, CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE, &dwRegistration); // wait on an event to stop WaitForSingleObject(hEvent, INFINITE); // revoke and release the class object CoRevokeClassObject(dwRegistration); ulRef = pCF->Release(); // Tell OLE we are going away. CoUninitialize(); return(0); } extern CLSID CLSID_CHello; extern UUID LIBID_CHelloLib; CLSID CLSID_CHello = { /* 2573F891-CFEE-101A-9A9F-00AA00342820 */ 0x2573F891, 0xCFEE, 0x101A, { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 } }; UUID LIBID_CHelloLib = { /* 2573F890-CFEE-101A-9A9F-00AA00342820 */ 0x2573F890, 0xCFEE, 0x101A, { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 } }; #include <windows.h> #include <ole2.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include "pshlo.h" #include "shlo.hxx" #include "clsid.h" int _cdecl main( int argc, char * argv[] ) { HRESULT hRslt; IHello *pHello; ULONG ulCnt; IMoniker * pmk; WCHAR wcsT[_MAX_PATH]; WCHAR wcsPath[2 * _MAX_PATH]; // get object path wcsPath[0] = '\0'; wcsT[0] = '\0'; if( argc > 1) { mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1); wcsupr(wcsPath); } else { fprintf(stderr, "Object path must be specified\n"); return(1); } // get print string if(argc > 2) mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1); else wcscpy(wcsT, L"Hello World"); printf("Linking to object %ws\n", wcsPath); printf("Text String %ws\n", wcsT); // Initialize the OLE libraries hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED); if(SUCCEEDED(hRslt)) { hRslt = CreateFileMoniker(wcsPath, &pmk); if(SUCCEEDED(hRslt)) hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&pHello); if(SUCCEEDED(hRslt)) { // print a string out pHello->PrintSz(wcsT); Sleep(2000); ulCnt = pHello->Release(); } else printf("Failure to connect, status: %lx", hRslt); // Tell OLE we are going away. CoUninitialize(); } return(0); }

    Read the article

  • Interop effects by resolving and instantiating types with ArcObjects

    - by Marko Apfel
    Problem this code does not work Type t = typeof(ESRI.ArcGIS.Framework.AppRefClass); System.Object obj = Activator.CreateInstance(t); but yet this code Type t = Type.GetTypeFromCLSID(typeof(ESRI.ArcGIS.Framework.AppRefClass).GUID); System.Object obj = Activator.CreateInstance(t); Reason In the first variant the runtime tries to cast to AppRefClass . This is not possible. And in the second one, the runtime does not knows anything about AppRefClass. So it leave it as IUnknown.   (originally communicated by my co-worker Ralf)

    Read the article

  • Pointless 'MIDL_INTERFACE' Macro in winapi?

    - by nebukadnezzar
    After browsing some old code, I noticed that some classes are defined in this manner: MIDL_INTERFACE("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX") Classname: public IUnknown { /* classmembers ... */ }; However, the macro MIDL_INTERFACE is defined as: #define MIDL_INTERFACE(x) struct in C:/MinGW/include/rpcndr.h (somewhere around line 17). The macro itself is rather obviously entirely pointless, so what's the true purpose of this macro?

    Read the article

  • Outlook Addin: DispEventAdvise exception.

    - by framara
    I want to creating an addin that captures when a {contact, calendar, task, note} is {created, edited, removed}. I have the following code, to make it shorter I removed all the code but the related to contact, since all types will be the same I guess. AutoSync.h class ATL_NO_VTABLE AutoSync : public wxPanel, public IDispEventSimpleImpl<1, AutoSync, &__uuidof(Outlook::ItemsEvents)>, public IDispEventSimpleImpl<2, AutoSync, &__uuidof(Outlook::ItemsEvents)>, public IDispEventSimpleImpl<3, AutoSync, &__uuidof(Outlook::ItemsEvents)> { public: AutoSync(); ~AutoSync(); void __stdcall OnItemAdd(IDispatch* Item); /* 0xf001 */ void __stdcall OnItemChange(IDispatch* Item); /* 0xf002 */ void __stdcall OnItemRemove(); /* 0xf003 */ BEGIN_SINK_MAP(AutoSync) SINK_ENTRY_INFO(1, __uuidof(Outlook::ItemsEvents), 0xf001, OnItemAdd, &OnItemsAddInfo) SINK_ENTRY_INFO(2, __uuidof(Outlook::ItemsEvents), 0xf002, OnItemChange, &OnItemsChangeInfo) SINK_ENTRY_INFO(3, __uuidof(Outlook::ItemsEvents), 0xf003, OnItemRemove, &OnItemsRemoveInfo) END_SINK_MAP() typedef IDispEventSimpleImpl<1, AutoSync, &__uuidof(Outlook::ItemsEvents)> ItemAddEvents; typedef IDispEventSimpleImpl<2, AutoSync, &__uuidof(Outlook::ItemsEvents)> ItemChangeEvents; typedef IDispEventSimpleImpl<3, AutoSync, &__uuidof(Outlook::ItemsEvents)> ItemRemoveEvents; private: CComPtr<Outlook::_Items> m_contacts; }; AutoSync.cpp _NameSpacePtr pMAPI = OutlookWorker::GetInstance()->GetNameSpacePtr(); MAPIFolderPtr pContactsFolder = NULL; HRESULT hr = NULL; //get folders if(pMAPI != NULL) { pMAPI-GetDefaultFolder(olFolderContacts, &pContactsFolder); } //get items if(pContactsFolder != NULL) pContactsFolder-get_Items(&m_contacts); //dispatch events if(m_contacts != NULL) { //HERE COMES THE EXCEPTION hr = ItemAddEvents::DispEventAdvise((IDispatch*)m_contacts,&__uuidof(Outlook::ItemsEvents)); hr = ItemChangeEvents::DispEventAdvise((IDispatch*)m_contacts,&__uuidof(Outlook::ItemsEvents)); hr = ItemRemoveEvents::DispEventAdvise((IDispatch*)m_contacts,&__uuidof(Outlook::ItemsEvents)); } somewhere else defined: extern _ATL_FUNC_INFO OnItemsAddInfo; extern _ATL_FUNC_INFO OnItemsChangeInfo; extern _ATL_FUNC_INFO OnItemsRemoveInfo; _ATL_FUNC_INFO OnItemsAddInfo = {CC_STDCALL,VT_EMPTY,1,{VT_DISPATCH}}; _ATL_FUNC_INFO OnItemsChangeInfo = {CC_STDCALL,VT_EMPTY,1,{VT_DISPATCH}}; _ATL_FUNC_INFO OnItemsRemoveInfo = {CC_STDCALL,VT_EMPTY,0}; The problems comes in the hr = ItemAddEvents::DispEventAdvise((IDispatch*)m_contacts,&__uuidof(Outlook::ItemsEvents)); hr = ItemChangeEvents::DispEventAdvise((IDispatch*)m_contacts,&__uuidof(Outlook::ItemsEvents)); hr = ItemRemoveEvents::DispEventAdvise((IDispatch*)m_contacts,&__uuidof(Outlook::ItemsEvents)); It gives exception in 'atlbase.inl' when executes method 'Advise': ATLINLINE ATLAPI AtlAdvise(IUnknown* pUnkCP, IUnknown* pUnk, const IID& iid, LPDWORD pdw) { if(pUnkCP == NULL) return E_INVALIDARG; CComPtr<IConnectionPointContainer> pCPC; CComPtr<IConnectionPoint> pCP; HRESULT hRes = pUnkCP->QueryInterface(__uuidof(IConnectionPointContainer), (void**)&pCPC); if (SUCCEEDED(hRes)) hRes = pCPC->FindConnectionPoint(iid, &pCP); if (SUCCEEDED(hRes)) //HERE GIVES EXCEPTION //Unhandled exception at 0x2fe913e3 in OUTLOOK.EXE: 0xC0000005: //Access violation reading location 0xcdcdcdcd. hRes = pCP->Advise(pUnk, pdw); return hRes; } I can't manage to understand why. Any sugestion here? Everything seems to be fine, but obviously is not. I've been stucked here for quite a long time. Need your help, thanks.

    Read the article

  • IE attachEvent on object tag causes memory corruption

    - by larswa
    I've an ActiveX Control within an embedded IE8 HTML page that has the following event MessageReceived([in] BSTR srcWindowId, [in] BSTR json). On Windows the event is registered with OCX.attachEvent("MessageReceived", onMessageReceivedFunc). Following code fires the event in the HTML page. HRESULT Fire_MessageReceived(BSTR id, BSTR json) { CComVariant varResult; T* pT = static_cast<T*>(this); int nConnectionIndex; CComVariant* pvars = new CComVariant[2]; int nConnections = m_vec.GetSize(); for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++) { pT->Lock(); CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex); pT->Unlock(); IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p); if (pDispatch != NULL) { VariantClear(&varResult); pvars[1] = id; pvars[0] = json; DISPPARAMS disp = { pvars, NULL, 2, 0 }; pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL); } } delete[] pvars; // -> Memory Corruption here! return varResult.scode; } After I enabled gflags.exe with application verifier, the following strange behaviour occur: After Invoke() that is executing the JavaScript callback, the BSTR from pvars[1] is copied to pvars[0] for some unknown reason!? The delete[] of pvars causes a double free of the same string then which ends in a heap corruption. Does anybody has an idea whats going on here? Is this a IE bug or is there a trick within the OCX Implementation that I'm missing? If I use the tag like: <script for="OCX" event="MessageReceived(id, json)" language="JavaScript" type="text/javascript"> window.onMessageReceivedFunc(windowId, json); </script> ... the strange copy operation does not occur. The following code also seem to be ok due to the fact that the caller of Fire_MessageReceived() is responsible for freeing the BSTRs. HRESULT Fire_MessageReceived(BSTR srcWindowId, BSTR json) { CComVariant varResult; T* pT = static_cast<T*>(this); int nConnectionIndex; VARIANT pvars[2]; int nConnections = m_vec.GetSize(); for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++) { pT->Lock(); CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex); pT->Unlock(); IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p); if (pDispatch != NULL) { VariantClear(&varResult); pvars[1].vt = VT_BSTR; pvars[1].bstrVal = srcWindowId; pvars[0].vt = VT_BSTR; pvars[0].bstrVal = json; DISPPARAMS disp = { pvars, NULL, 2, 0 }; pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL); } } delete[] pvars; return varResult.scode; } Thanks!

    Read the article

  • Path is too long

    - by kaleidoscope
    Bugged by the irritating "Path is too long after being fully qualified" error while running in the Development Fabric? The solution is pretty funny and not so obvious unfortunately. The culprit here is not your app, but the Development Fabric. The DevFab accumulates a lot of temporary junk comprising of local storage locations, cached binaries, configuration, diagnostics information and cached compiled web site content files over its lifetime. They are typically stored at C:\Users\<username>\AppData\Local\dftmp. The Azure Tools will periodically clean this up, but some time you have to play janitor and take the law in your hands ;). The csrun.exe has quite a few tricks up its sleeve. One of them is the ability to clean the development fabric's temporary junk accumulated over time. You can do this by  running the Azure command prompt with elevated privileges and running csrun.exe /devfabric:shutdown and then csrun.exe /devfabric:clean If the problem still persists then the application directory structure could indeed be too long. A workaround to this is changing the Development Fabric temporary directory to point to a shorter path. The temporary directory path can be addressed by an environment variable _CSRUN_STATE_DIRECTORY. You can try setting its value to something like "C:\WA" or "C:\A" this will reduce some 25+ characters from your path. Do not forget to close Visual Studio and expressly shutdown the dev fab with csrun.exe /devfabric:shutdown (Under elevated privileges of course). Source: http://geekswithblogs.net/IUnknown/archive/2010/02/03/no-more-path-is-too-long.aspx  :D   Sarang, K

    Read the article

  • Why don't Direct2D and DirectWrite use traditional COM objects?

    - by David Brown
    I'm toying with a little 2D game engine in C# and decided to use Direct2D and DirectWrite for rendering. I know there's the Windows API Code Pack and SlimDX, but I'd really like to dig in and write an interface from scratch. I'm trying to do it without Managed C++, but Direct2D and DirectWrite don't appear to use traditional COM objects. They define interfaces that derive from IUnknown, but there appears to be no way to actually use them from C# with COM interop. There are IIDs in d2d1.h, but no CLSID. Of course, I'm really new to COM interop, so perhaps I'm just missing something. Can someone shed some light on this situation?

    Read the article

  • Passing a SAFEARRAY from C# to COM

    - by SlavaGu
    I use 3rd party COM to find faces in a picture. One of the methods has the following signature, from SDK: long FindMultipleFaces( IUnknown* pIDibImage, VARIANTARG* FacePositionArray ); Parameters: pIDibImage[in] - The image to search. FacePositionArray[out]- The array of FacePosition2 objects into which face information is placed. This array is in a safe array (VARIANT) of type VT_UNKNOWN. The size of the array dictates the maximum number of faces for which to search. which translates into the following C# method signature (from metadata): int FindMultipleFaces(object pIDibImage, ref object pIFacePositions); Being optimistic I call it the following way but get an exception that the memory is corrupt. The exception is thrown only when a face is present in the image. FacePosition2[] facePositions = new FacePosition2[10]; object positions = facePositions; int faceCount = FaceLocator.FindMultipleFaces(dibImage, ref positions); What's the right way to pass SAFEARRAY to unmanaged code?

    Read the article

  • java-COM interop: Implement COM interface in Java

    - by mdma
    How can I implement a vtable COM interface in java? In the old days, I'd use the Microsft JVM, which had built in java-COM interop. What's the equivalent for a modern JRE? Answers to a similar SO question proposed JACOB. I've looked at JACOB, but that is based on IDispatch, and is aimed at controlling Automation serers. The COM interfaces I need are custom vtable (extend IUnknown), e.g. IPersistStream, IOleWindow, IContextMenu etc. For my use case, I could implement all the COM specifics in JNI, and have the JNI layer call corresponding interfaces in java. But I'm hoping for a less painful solution. It's for an open source project, so open source alternatives are preferred.

    Read the article

  • How do I create interface methods using .tlb types in VS C++?

    - by Steven
    Background: The .TLB file contains interfaces written in language 'X'. I don't have .h, .idl, .tlh, or any other header files - just the .TLB file. Language 'X' does not export compatible .h, .idl, etc. I use the VS wizard to add an ATL simple object to my ATL project. I want to add a method to the interface of my simple ATL object that uses one of the .TLB defined types for a parameter. // Something like the following in the .idl file: interface ISomeInterface : IUnknown { HRESULT SomeMethod([in] ITypeFromTLB* aVal); // ITypeFromTLB declared in .TLB file. }; How can I do this? I'm hoping for a wizard, or a line in the .idl interface declaration that would bring in the .tlb information. midl's include (no .tlb), import (no tlb), and importlib (library only) don't seem to provide a solution (I need proxy/stub to be working, so I cannot put this inside the library declaration with the importlib command). Thanks.

    Read the article

  • Newbie questions about COM

    - by smwikipedia
    Hi, I am quite new to COM so the question may seem naive. Q1. About Windows DLL Based on my understanding, a Windows DLL can export functions, types(classes) and global variables. Is this understanding all right? Q2. About COM My naive understanding is that: a COM DLL seems to be just a new logical way to organize the functions and types exported by a standard Windows DLL. A COM DLL exports both functions such as DllRegisterServer() and DllGetClassObject(), and also the Classes which implements the IUnknown interface. Is this understanding all right? Q3. *.def & *.idl *.def is used to define the functions exported by a Windows DLL in the traditional way, such as DllGetClassObject(). *.idl is used to define the interface implemented by a COM coclass. Thanks in advance.

    Read the article

1 2  | Next Page >