|
I have a COM Class in Vb.Net the code is like this
<comclass(class1.classid, class1.interfaceid,="" class1.eventsid)=""> _
Public Class Class1
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "74eb4206-6063-4ea1-b499-bfdd9f49f4bf"
Public Const InterfaceId As String = "ff2cdb8a-e1f9-464b-bb6f-ead5812d3630"
Public Const EventsId As String = "a8880b84-9a33-41f2-90f6-c6141835ee61"
#End Region
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub
Public Function MergeFiles(ByVal arrFiles() As String, ByVal strOutputFile As String) As String
End Function
End Class
When imported in VC++ (6.0) we are not able to get the function out. Any suggestions
|
|
|
|
|
Hmmm - you're using VB.NET but still using VC++ 6.0? That makes no sense what so ever...there's so much good support for importing COM objects easily in later versions of VC++...look up #import....
Open the type library for VB.NET DLL in the OLE/COM Object Viewer (open the Type Libraries branch of the tree view and select your project's type library - it'll be named after your project) to see what interfaces and classes the DLL exports. This'll show the DLL is properly registered and also show you what object you have access to.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
I'm using VC6 and the MapWindowGIS control, MapWindowGIS.OCX. It has many interfaces but few examples on how to use it using VC6. I'm kind of new to using COM so my terminology is probably incorrect to some degree.
The problem is I can get to one of the interfaces, IShapeFile, using their example using:
IShapefilePtr* pShapeFile = new IShapefilePtr;
HRESULT hr = pShapeFile->CreateInstance(__uuidof(Shapefile));
CreateInstance(), but when I try this on other interfaces such as IGrid and IGridHeader, CreateInstance() fails with the "Class Not Registered" error (0x80040154).
Since, the control, MapWindowGIS.OCX is registered, and I was able to get the IShapeFile interface, I'm assuming that I need to call QueryInterface() but the IGrid and IGridHeader interfaces are not part of the IShapeFile interface. So, I'm assuming then I need to get a pointer to the MapWindowGIS control but I'm not instantiating it directly since it is #import(ed).
VC6 created the .tli and tlh files and a CWnd derived class from the OCX called, CMap1. Is there something I can call in CMap1 that will return the main object's interface pointer so I can then call QueryInterface()?
|
|
|
|
|
JohnnyG wrote: I was able to get the IShapeFile interface, I'm assuming that I need to call QueryInterface() but the IGrid and IGridHeader interfaces are not part of the IShapeFile interface
No, but you normally would get, say, an IGridHeader interface by using the IShapeFile interfaces method QueryInterface asking it for an IGridHeader interface. All interfaces inherit from the base interface IUnknown which has three methods, QueryInterface being one of them. Having got one interface you can then use its QueryInterface method to get another interface implemented by the object.
|
|
|
|
|
Well, I'm kind of at a loss because I tried that with the IShapeFile interface (meaning I called QueryInterface for the IGrid interface on the IShapeFile interface) and I'm getting the E_NOINTERFACE error. That is why I was asking about how I get a interface pointer from the OCX control itself.
All of the examples are for VS 2008 in C# and VB.net. The only example they provide for VC6 is for creating a map using a shapefile hence, the IShapeFile interface.
I have the CLSID for the OCX is there some way I can get its main interface or IUnknown interface from the OCX using this CLSID ??
modified on Monday, April 26, 2010 5:19 PM
|
|
|
|
|
A search took me to the Mapwindow Wiki [^] where it says "An ESRI grid manager object provides functions which facilitate using ESRI grids with MapWinGIS". So it sounds to me as if you should be looking to work with the GridManager before trying to get an IGrid or IGridHeader.
|
|
|
|
|
Hello,
I need to write a stub(module), when given some PE (DLL/EXE) as input , it should give the information that this PE is Win32 DLL/EXE or COM DLL/EXE? I need it programatically to determine this.
Is there any windows APIs?
Regards
Usman
|
|
|
|
|
A normal COM dll will have the the following exported functions:
Out of these, DllGetClassObject is the main one.
Use the GetProcAddress[^] to test for the presence of these functions.
Telling if an EXE is a COM exe is not really practical.
Steve
|
|
|
|
|
Yeah..!!
This one can be a good alternative.
But its rather an out of the way we need to go. I think there would be some other straight froward methods might be available to have this information. like some flag or bit that will tell us about whether its COM PE or simple Win32 DLL /EXE
|
|
|
|
|
No, there's not. A DLL, an EXE, a COM-DLL and a COM-EXE are all PE files. There is nothing magical about COM components as far as PE files are concerned.
Steve
|
|
|
|
|
More over DLL Exe won't have these methods.
and what if user define its own methods with these names in WIN32 DLL's and WIN32 EXE's.
I think there would be some more generic way out to check whether these are COM EXE,COM DLL's OR Win32 EXE's or Win32 DLL's.
Regards
Usman
|
|
|
|
|
There's nothing special about a COM exe. In general you'd call a DLL a COM-DLL if:
- It's registered.
- It exports
DllGetClassObject .
For an EXE:
- It's registered.
- When ran it calls CoRegisterClassObject[^]
to hook up its class objects to the COM runtime.
Notice that registration is not a property intrinsic to a PE file. Also there are ways a PE file could be considered a COM module and not even do all of the above:
- It could implement COM objects and make them available via some factory method. This pattern is used quite frequently.
- It could use some other method to make its objects available, such as the running object table.
- Even DLLs can use
CoRegisterClassObject to make its class objects available. I've used this technique to implement registration-free COM many times.
There are no magic flags and none are needed.
Steve
|
|
|
|
|
Try registering and look at the result? Or search the COM registry area for a reference to that dll/exe?
|
|
|
|
|
Why do you need to do this?
|
|
|
|
|
I was wondering that too.
Steve
|
|
|
|
|
Hello All,
I am working on an OPC HDA Client where I am creating a Conenction with OSI PI HDA Server via below code. But at the time of Advise to the Server I am getting an error with error code = 0x80040202. The OSI HDA server is located on remote machine which has full DCOM configuration. I searched out and found that this happens due to CONNECT_E_ADVISELIMIT or CONNECT_E_CANNOTCONNECT. Below is the my code of Connect(). Can anybody help me what else I have to do to fix the problem.
void HdaServer::Connect()
{
try
{
Debugger::Launch();
OpcServer::Connect();
#pragma region Code Added For AsyncOperations
ATL::CComPtr<::IConnectionPointContainer> subscripCpcObj = GetAtlInterface<::IConnectionPointContainer>((this->RawObject));
ATL::CComPtr<::IConnectionPoint> eventObjPtr;
HRESULT hr = subscripCpcObj->FindConnectionPoint(__uuidof(IOPCHDA_DataCallback), &eventObjPtr);
this->CheckResult(hr);
IntPtr cbPtr = Marshal::GetComInterfaceForObject(this, OpcHdaEventSink::typeid);
ATL::CComQIPtr<IOPCEventSink> callbackPtr;
callbackPtr = reinterpret_cast<IOPCEventSink*>(cbPtr.ToPointer());
DWORD cookie;
hr = eventObjPtr->Advise(callbackPtr, &cookie);
this->CheckResult(hr);
this->callbackCookie = cookie;
this->callbackConnectionPoint = GetDotNetInterface<::IConnectionPoint>(eventObjPtr);
if(this->callbackConnectionPoint == nullptr)
{
OutputDebugString(L"HdaServer:->callbackConnectionPoint is NULL!");
}
#pragma endregion
}
catch(Exception^ ex)
{
throw ex;
}
}
ANURAG VISHNOI,
Sr. Software Engineer,
|
|
|
|
|
The IConnectionPoint::Advise implementation contains:
...
hRes = pUnkSink->QueryInterface(iid, (void**)&p);
....
else if (hRes == E_NOINTERFACE)
hRes = CONNECT_E_CANNOTCONNECT;
if (FAILED(hRes))
*pdwCookie = 0;
return hRes;
Maybe you are getting CONNECT_E_CANNOTCONNECT because E_NOINTERFACE was returned by the QI call?
|
|
|
|
|
Hey tanks for the answer. But the question how can I solve this issue. Because I am able to connect with other servers but not with a specific type. Advise() fails only for OSI.HDA Server.
Thanks,
Anurag
ANURAG VISHNOI,
Sr. Software Engineer,
|
|
|
|
|
Hello sir,
I have created the COM component in VC6.0 using ATL 3.0
I am using it in VB6.0
I have added the BSTR Event.
I want to pass the string with NULL character in between the string from VC to VB
e.g. I want to fire a event with string "ABC\0XYZ"
So I can get the complete string in VB as ABC[]XYZ
[] - indicates box as unicode character.
But I am getting only "ABC" string.
Please tell me the way to pass the string with NULL character from vc to vb.
It's very urgent.
Please do the needful.
Thanks.
|
|
|
|
|
Note: Without seeing any of your code, I'm just guessing...
It's probably because when you create the BSTR, you let it count characters to determine its length, rather than telling it what the length actually is. Any string length function in C/C++ will see a NULL as the end of string.
So, create your BSTR like this, telling it what its length is:
BST b = SysAllocStringLen(L"ABC\0XYZ", 7);
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Still I am getting only ABC in VB
So please tell me how to send full string.
I am getting what you have told me. but I want to transfer this full string from vc to vb.
So please tell me the solution
It's very urgent
Thanks for help.
|
|
|
|
|
This begs an obvious question: can VB handle strings with embedded NULLs? Many of C's CRT functions such as wcscmp can't for example.
Steve
|
|
|
|
|
As I recall you won't be able to do as you want, either the ATL Event Wizard generated code sees the internal NULL and loses the rest (even with the BSTR length set) or VB will see a a NULL terminated string. I'm pretty sure You'll have do do more one way or the other. Maybe pass an array of characters?
|
|
|
|
|
The NULL character is your problem. Try replacing it with some other unique Unicode character which both parts of your application can recognise. Alternatively put the box character in your source string in the first place.
It's time for a new signature.
|
|
|
|
|
Hello Friends
I am using namespace MSXML in my application to traverse and read XML file.But I have some confusion regarding MSXML is that this one is related to c++ DOM APIs na? And what its relation with COM?
And these both COM AND DOM are provoding different APIs?and then what is DCOM?
Please Suggest me something.I am too confused.
Thanks & Regards
Yogesh
|
|
|
|