|
|
In the end I gave up and adapted IThumbnailProvider sample from WinSDK.
http://www.autohotkey.net/~T800/TEMP/CBXShell%204.0.0.2.rar
I would say that M$ is internally using something else beside ATL for com and selling us their high-price pro-bloatware, because that sample uses previously undocumented, but yet availabe even in win2000, by-ordinal exported functions from Shlwapi.dll.
Hmmm... this sample will come in handy , you can adapt it to your needs in 10 mins, instead losing time with ATL wizards.
Now it all works OK, on XP and Vista (still gotta test x64), beside the fact that Explorer stubbornly caches/doesn't unload dll when it's not needed (but it's OK since (un)installer will do a reboot).
I traced interface calls and it is incredible to see such M$-incompetence (parts of output from a few runs, just for an illustration), look at that inconsistent mess:
CCBXShell::CCBXShell
IInitializeWithFile::Initialize
CCBXArchive::OnLoad
IExtractImage::GetLocation
CCBXArchive::OnGetLocation
IThumbnailProvider::GetThumbnail
CCBXArchive::OnGetLocation
CCBXArchive::OnExtract
CCBXShell::~CCBXShell
CCBXShell::CCBXShell
IInitializeWithFile::Initialize
CCBXArchive::OnLoad
IExtractImage::GetLocation
CCBXArchive::OnGetLocation
IThumbnailProvider::GetThumbnail
CCBXArchive::OnGetLocation
CCBXArchive::OnExtract
CCBXShell::~CCBXShell
CCBXShell::CCBXShell
IInitializeWithFile::Initialize CCBXArchive::OnLoad
IExtractImage::GetLocation CCBXArchive::OnGetLocation
IThumbnailProvider::GetThumbnail CCBXArchive::OnGetLocation CCBXArchive::OnExtract
CCBXShell::CCBXShell
IInitializeWithFile::Initialize CCBXArchive::OnLoad CCBXArchive::OnGetInfoTip
CCBXShell::~CCBXShell
CCBXShell::~CCBXShell
|
|
|
|
|
It looks that Vista is very stubborn about thumbnails. It seems that my first version (the one with IExtractimage) works after all (go figure).
I forcefully deleted Vista thumbnail cache files (inside C:\Users\T800\AppData\Local\Microsoft\Windows\Explorer\) and now it seems to work OK. (I needed a bigger hammer )
Btw, I think that IThumbnailProvider example from SDK still has bugs, but I'm not wasting my time with it now.
Merry Xmas and happy New year! ![Rose | [Rose]](https://codeproject.global.ssl.fastly.net/script/Forums/Images/rose.gif)
|
|
|
|
|
Hi,
How can i pass a collection object as a parameter ....???
Consider below example..
Interface IMyInterface
{
void DisplayData(??????);
}
Class MyClass : IMyInterface
{
void IMyInterface.DisplayData(??????)
{
Logic to display data
Display First Name ,
Display last name...
}
}
///From client.
Class Client
{
//I have a data structure (some data container) , which saves data like <key , value> say a map...
MyClass myclass = new MyClass()
myclass.DisplayData( ???)
}
Now what should be the parameter typr ???
|
|
|
|
|
Hi Everyone,
I need help. My deadline is tomorrow and I have been at this for almost 2 weeks now. I need to call a com object from a C# or VB.NET dll that is called by a third party app (TIPCO).
The com object takes in a string and returns a string.
I have the following:
1. A .net dll that calls the com (my wrapper)
2. A .net dll that calls my wrapper dll and this is the entry point for calling applications (basically .net is my intermediary)
(Please not when referring to a dll I am referring to a class library object)
My Code looks as follows
My C# dll that calls the com object (wrapper)
I have a C# wrapper that calls the com object
Public Class Class1
Public Sub callMagicDLL(ByRef input As Integer, ByRef output As Integer)
Dim myownClass As New CallWithMain()
myownClass.Main()
End Sub
End Class
Imports System.Runtime.CompilerServices
Imports System.Runtime.InteropServices
Public Class CallWithMain
Dim a As Integer
Dim b As Integer
<STAThread()> _
Sub Main()
Dim mymagicdll As New magic.magic 'Com object
Dim a As Integer = 1
Dim b As Integer = 1
mymagicdll.magicdll(a, b)
End Sub
End Class
Then another C# dll project to call the dll above, that consists of an interface and a class that implement it
Option Strict Off
Option Explicit On
Imports com.tibco.matrix.clr
Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Web.Services
Imports System.Xml.Serialization
Namespace www.example.com.com.tibco.amx.sample.helloworld.simple.java.soa
'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.1433"), _
WebServiceInterface(MethodParameters:="InputMsg", PortTypeName:="HelloWorldPT", PortTypeNamespace:="http://www.example.com/com.tibco.amx.sample.helloworld.simple.java.soa/", WSDLLocation:="HelloWorld_HelloWorldPT.wsdl")> _
Public Interface IHelloWorldPT
'''<remarks/>
<System.Web.Services.WebMethodAttribute()> _
Function sayHello(<System.Xml.Serialization.XmlElementAttribute([Namespace]:="http://ns.tibco.com/Hello/")> ByVal HelloRequest As String) As String
End Interface
End Namespace
And then the class that implements the interface
Imports com.tibco.matrix.clr
Namespace ActiveMatrixComponent1
<ServiceImplementation()> Public Class HelloWorld_HelloWorldPTImpl
Implements www.example.com.com.tibco.amx.sample.helloworld.simple.java.soa.IHelloWorldPT
Dim log As System.Diagnostics.TraceSource
Public Sub New()
log = Funcs.ts
End Sub
Public Function sayHello(ByVal HelloRequest As String) As String Implements www.example.com.com.tibco.amx.sample.helloworld.simple.java.soa.IHelloWorldPT.sayHello
Dim a1 As Integer = 1
Dim b1 As Integer = 2
Dim dllWrapper As New CallingMagicDLLWrapper.Class1
dllWrapper.callMagicDLL(a1, b1)
Return "dot net : " & Trim(Convert.ToString(b1))
End Function
End Class
End Namespace
I did implement
<STAThread()> _
On my main method in my class that calls the dll.
If I run the code as it is I get the following error. And I don’t seem to get pass that.
CallServiceImpl: Unable to cast COM object of type 'magic.magicClass' to interface type 'magic.Dmagic'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{F1556D77-4488-489D-8B1F-53FC0F7AC312}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).; on machine = DHN00807
Stack trace: at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at magic.magicClass.magicdll(Int32 pMagicRequestXML, Int32& prMagicResponseXML)
at CallingMagicDLLWrapper.CallWithMain.Main()
at CallingMagicDLLWrapper.Class1.callMagicDLL(Int32& input, Int32& output)
at ActiveMatrixComponent1.ActiveMatrixComponent1.HelloWorld_HelloWorldPTImpl.sayHello(String HelloRequest)
I read on the internet and it seems like I need to set the thread to STA.
If I try to set the current thread (in my wrapper class before I call the COM object)
Thread.CurrentThread.SetApartmentState(ApartmentState.STA)
I do get an error that it cannot be set. If I create my own thread and set the new thread state to STA it works but I don’t know how to get the data back once the thread is done. And if I do it this way and call it over and over (17 odd times) it falls over.
(I can call my .NET dll from the TIPCO app and send and retrieve data. But as soon as I call the .NET dll that calls the .NET wrapper dll that calls the COM object it falls over with the above error. I can call the above from a new windows application and then everything works but as soon as I call it from an outside .NET application I get the error).
Any suggestions please? It will help a lot.
Thanks
Chris
|
|
|
|
|
Chris Tiaan wrote: My C# dll that calls the com object (wrapper)
I have a C# wrapper that calls the com object
I don't see any C# code here, it looks to me like Visual Basic. You might get better help posting this in the VB forum.
|
|
|
|
|
You are shure that 'magic.Dmagic' interface is implemented in the 'magic.magicClass'?
Be shure that all components are created and running in the same Thread model or you never wont get rid of bad trouble.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi,
I don't know exactly is this the right forum to post this question, can anyone tell me how to hide one of the output pin in a direct show source filter?
Thank you in Advance.
Raja Bose
|
|
|
|
|
Hi,
I am working on Excel automation using VC++(unmanaged).
imports:
#import "libid:00020813-0000-0000-C000-000000000046" auto_search no_dual_interfaces \
rename("DialogBox", "excelDialogBox") \
rename("RGB", "excelRGB") \
rename("DocumentProperties", "excelDocumentProperties") \
rename("SearchPath", "excelSearchPath") \
rename("CopyFile", "excelCopyFile") \
rename("ReplaceText", "excelReplaceText")
Following are the two issues:
1. Whenever Excel is closed , Excel.EXE is not getting closed.
My application should track opening and closing of Excel.
I released application pointer(Excel::_ApplicationPtr) but same problem.
I googled and got few solutions, but nothing worked.
I tried :
Excel::_ApplicationPtr XL.
And getting the active object of excel using GetActiveObject.
XL->Quit();
XL->Release();
XL = NULL;
but none of these worked.
Is there any similar method like Marshal.ReleaseComObject in UNmanaged VC++?
2. Is there any callback which tracks excel.exe is closed?
Please give me clue to solve these issues.
Regards,
KTTransfer.
|
|
|
|
|
AFAIK, to close Excel application you have to create it via CoCreateInstance
|
|
|
|
|
I want to use an interface method in my com class . Now this can be archive by two ways
1) by importing tlb file in idl file.
ii) by including/adding .h file.
Can you please explain the diff betn approach i and ii and in which scenario we should use them?
|
|
|
|
|
Reading from my COM IDL & Interface Design by Al Major (Wrox):
#include
The contents of the #included file are placed in the idl as if they had been typed in.
import
Is the standard method for bringing in definitions from other idl, odl or C/C++ header files into the main IDL file
Al recommends: not using #include unless you need to support legacy types and using: import to get at IDL declarations.
|
|
|
|
|
Importing using #import can be used to instantiate a COM component from its type library that is either embedded inside the DLL or as a separate file (.TLB file).
This method prompts the compiler to create the header files which is automatically included in the generated source codes.
It also create smart pointer for all the exposed interfaces using the _com_ptr_t class. The smart pointers will have a naming convention of xxxPtr where xxx is the name of the exposed interface.
The method of #include is a more basic approach where you use the standard COM APIs like CoCreateInstance to instantiate and use the COM component. You will have to manually create smart pointers if needed.
|
|
|
|
|
Good Morning,
I need to call a dll from C# that was generated by magic edeveloper. I think it is a C dll.
It is a program that takes in 3 parameters all integers. Adds the first to and pass the sum to the 3rd parameter.
I have registered the dll in windows and I can add a reference in visual studio via the Project Add Reference menu.
I have the following code in my project
int a = 5;
int b = 6;
int sum = 0;
double sumDouble = 0;
sumdll.sumdllClass sdc = new sumdll.sumdllClass();
sumDouble = sdc2.sumdll(ref a, ref b, ref sum);
But if I run it I get the error
Unable to cast COM object of type 'sumdll.sumdllClass' to interface type 'sumdll.Dsumdll'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{3DC9FCBA-9E72-49AA-B597-F9B2603D5EEA}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
the following is available from the intellisense
sumdll.sumdllClass sdc = new sumdll.
Dsumdll which is an interface
Sumdll which is an interface
sumdllClas which is a class
And in the line
sumDouble = sdc2.sumdll(
ref int input1, ref int input2, ref @input)
Does anyone know I am getting this error? Or how to call the dll correctly.
Regards,
Christiaan Pieters
|
|
|
|
|
Ok so I tried to do the same thing in VB.NET. I usally work in a console application for ease and once I have succeded I will convert or redo what every I have to do.
The console application in VB.NET is by default in a module.
If I do the following in VB.NET from the module
Console.WriteLine("Start")
Dim dllRef As New sumdll.sumdll()
Dim a As Integer = 10
Dim b As Integer = 18
Dim c As Integer = 0
Dim d As Double = 0.0
d = dllRef.sumdll(a, b, c)
Console.WriteLine("Done")
Console.WriteLine(a)
Console.WriteLine(b)
Console.WriteLine(c)
Console.WriteLine(d)
Console.Read()
But if I move the same code to a class I still get the same error as before. Why can’t this be called from a class? If I can get this to run from a class I am sure I will be able to call this from C#.
Thanks,
Christiaan
|
|
|
|
|
I can only give you the advice to use better names for your stuff. You are mixing interfaces and classes.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Well.. Do you try to register this dll in to the GAC?
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
I'd like to use Registration-Free Activation of .NET-Based Components to make my application side by side.
http://msdn.microsoft.com/en-us/library/ms973915.aspx#rfanetwalk_topic4
From this article, I can't get an idea to slove my issue.
Here is the calling logic in my application. I have a dll(done by delphi) to invoke a .NET COM, but the dll will be loaded in a .NET application. I tried to add a manifest with the executable file name, but always failed to load the .NET COM. (.NET Application <- Delphi DLL <- .NET COM)
I tried a Delphi application to load the .NET COM with manifest file and it is ok. Is it possible to attach the manifest inforamtion to a DLL????
can anyone help?
thanks in advance.
|
|
|
|
|
Hi All,
I have created COM component(dll) and created one client to use it, Please finnd the code of client:-
HRESULT hr = CoInitialize(0);
Please give me some solutions coz i tried every possible way.
Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
your code isnt readable.
What are the error codes? Google them
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi KarstenK,
I am getting value of hresult= -2147221164
Please find the code below:
HRESULT hr = CoInitialize(0);
//CoCreateInstance(
SCRIPTOBJLib::IScriptObjPtr sobj;
//sobj->QueryInterface(IId_,void* &vp);
//HRESULT hRes = CComObject<CScriptObj>::CreateInstance(&sobj);
//CreateInstance(NULL,IID_IUnknown,(void*)&vp);
HRESULT hres = sobj.CreateInstance ( __uuidof(SCRIPTOBJLib::IScriptObj) );
//HRESULT hres = sobj.CreateInstance("ScriptObj 1.0 Type Library");
sobj->SetLanguage((unsigned short *)"VBScript");
CoUninitialize();
Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
I think that the issue is that you are using getting the ID of the interface:
__uuidof(SCRIPTOBJLib::IScriptObj)
You need the ID of the coclass in the CreateInstance call. It is probably __uuidof(SCRIPTOBJLib::ScriptObj) depending on how the object has been implemented.
|
|
|
|
|
But from the library i am getting two things:
1.IScriptObj
2.IScriptObjptr
So what else i can try.
Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
Please use for HRESULT hexadecimal values (Just do it! if you want to run COM)
if you google that (-2147221164 => hex 80040154) you find things like "class not registered". This means that SCRIPTOBJLib::IScriptObj isnt registered properly. ->regsvr32
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I note the poster has two threads going on this question, one here and one in the C++ forum. I have now bowed out.
|
|
|
|