|
try return them as Object s
Cheers,
Suresh
|
|
|
|
|
Hi all,
I have static lib which i want to convert into COM DLL. so have write an IDL file.
In this IDL file i have to define a structure which contains another structure COLOR which is defined in "Gdiplus.h".
My question is whether i can add this header file "Gdiplus.h" in the IDL file?
If yes then how. note that after including the "Gdiplus.h" i have mention its namespace also which is Gdiplus.
I have done it by including #import "Gdiplus.h" but error such as this is generated
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\Gdiplus.h(25) : error MIDL2025 : syntax error : expecting an interface name or DispatchInterfaceName or CoclassName or ModuleName or LibraryName or a type specification near "namespace"
The IDL file for your reference...
//----------------------------------------------------------------------------
// File: Control.idl
//
// Desc: Interface definition for the IControl
//
//----------------------------------------------------------------------------
import "oaidl.idl";
import "ocidl.idl";
import "Gdiplus.h";
using namespace Gdiplus;
cpp_quote("// Structure containing the various color details of the meter display")
typedef struct _ColorInfo
{
Color NeedlePointerColor;
Color NeedleJointColor;
//Color TextColor;
COLORREF TextColor;
Color LargeGridColor;
Color SmallGridColor;
Color BackGroundColor;
// Constructor
_ColorInfo()
{
NeedlePointerColor = Color(255,163, 163, 163);
NeedleJointColor = Color(255,255, 255, 0);
//TextColor = Color(255,255, 255, 255);
TextColor = RGB(255, 255, 255);
LargeGridColor = Color(255,255, 255, 255);
SmallGridColor = Color(255,255, 255, 255);
BackGroundColor = Color(255, 0, 0, 0);
}
// Copy Constructor
_ColorInfo(const _ColorInfo &ColorInfo)
{
NeedlePointerColor = ColorInfo.NeedlePointerColor;
NeedleJointColor = ColorInfo.NeedleJointColor;
TextColor = ColorInfo.TextColor;
LargeGridColor = ColorInfo.LargeGridColor;
SmallGridColor = ColorInfo.SmallGridColor;
BackGroundColor = ColorInfo.BackGroundColor;
}
// Assignment operator overloading
_ColorInfo & operator = (const _ColorInfo &ColorInfo)
{
NeedlePointerColor = ColorInfo.NeedlePointerColor;
NeedleJointColor = ColorInfo.NeedleJointColor;
TextColor = ColorInfo.TextColor;
LargeGridColor = ColorInfo.LargeGridColor;
SmallGridColor = ColorInfo.SmallGridColor;
BackGroundColor = ColorInfo.BackGroundColor;
return *this;
}
} COLORINFO;
//-------------------------------------------------------------------------
// IControl Interface
// Desc: Exposes initialization method for the Control dll
//-------------------------------------------------------------------------
[
object,
uuid(5BC8F091-28C0-42aa-AD10-AA78E612D6AA),
version(1.0),
helpstring("IControl Interface"),
pointer_default(unique)
]
interface IControl : IUnknown
{
cpp_quote("// Displays the control")
[id(2), helpstring("method ShowControl")]
HRESULT ShowControl( );
}
//{5E3CE754-FCC9-454e-B4BE-D1DD470BAF1E}
//{ 0x5e3ce754, 0xfcc9, 0x454e, { 0xb4, 0xbe, 0xd1, 0xdd, 0x47, 0xb, 0xaf, 0x1e } };
[
uuid(5E3CE754-FCC9-454e-B4BE-D1DD470BAF1E),
helpstring("Meter Class")
]
coclass Meter
{
[default] interface IControl;
};
Can anyone help me.
Thanks,
Bidesh
|
|
|
|
|
MIDL keyword Include[^]may help.
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Hello everyone,
I am writing C# COM server (managed code). Since there is no QueryInterface, DllGetClassObject like in C++ native code, I am wondering how to know which coclass is initialized and which method is invoking by client?
I have such question is because I only develop COM server, and there are some dll level error (dll no longer available, something like this), so I think COM client may use some coclass/methods which my COM server does not support. But I do not have COM client source codes, so I am wondering how to get the information (which coclass/method client is using).
thanks in advance,
George
|
|
|
|
|
Hi,
I have a method which has to return the array of BSTRs. I'm giving the method here, please let me know if I'm doing anything wrong.
<br />
HRESULT Login([in] BSTR UserName, [in] BSTR Password, int maxUsrCnt , [out]int *UsrCnt, [out, length_is(,*UsrCnt), size_is(,maxUsrCnt)] BSTR *LoggedUsers);<br />
the size of the array to be returned is not known at the time of calling.
When I use this method, the first string is coming properly, but other strings are not coming.
Please suggest an answer.
Regards,
Raja Pratap
|
|
|
|
|
I'd avoid trying to mix BSTRs and custom marshalling. Instead, I'd go with a SAFEARRAY of BSTR . To return such an array to a VB client, I'm using:
HRESULT ExtendedHardwareType([out, retval] SAFEARRAY(BSTR)* psArray);
|
|
|
|
|
Thanks a ton Mike, working and its very easy to code.
|
|
|
|
|
I am using Microsoft Exchange 2003 to replicate mails and folders. but i am not able to replicate folders in exchange through my code. while looking at at the services, i found that the service named Microsoft Exchange Event is not started except the other services. On starting the service manually i get the message "Services Stop automatically if they do not have any work to do".
Ashish Vasudev
|
|
|
|
|
Hi all,
I have a VB.NET program that has a OLE COM object imbedded in the form, the OLE object can send information back to my program by using callback which is set up as a class.
In the Callback class I have a sub set up to handle every time the OLE window changes which works fine, now the fun begins. I set up another sub which takes a string from the sub receiving the callback message, it then uses this string to select a control on the main form like so
Dim pnl as Panel = Mainform.pnlLegend.Controls.Item({String})
When ever it gets to this line it throws the error "Current thread must be set to single thread apartment (STA) mode before OLE calls can be made".
I have searched all over the net looking but the only help I can find on this is stuff to do with remote clipboards. Hopefully someone on here maybe able to help me with this.
Thanks
Nathan
|
|
|
|
|
|
Thanks,
I had a look at the link you said, it helped a bit but I still can't get around this problem.
It seems like the form runs in STA mode but the class that is set to handle callbacks is set to MTA mode. I have tried to set the Apartment mode to STA in the callback class but it just throws the error: "Can not set to STA" or something along those lines.
As you can see I'm not 100% sure where I have to set the class to run in STA mode. I have tried to put the <stathread> above Main in both in the form and in the Class but no luck .
Can anyone help me on this one?
P.S I'm using VB.NET if I havn't said before
|
|
|
|
|
MadmanWoo wrote: In the Callback class I have a sub set up to handle every time the OLE window changes which works fine, now the fun begins. I set up another sub which takes a string from the sub receiving the callback message, it then uses this string to select a control on the main form like so
Dim pnl as Panel = Mainform.pnlLegend.Controls.Item({String})
When ever it gets to this line it throws the error "Current thread must be set to single thread apartment (STA) mode before OLE calls can be made".
I believe the problem happens because your callback and the control, whose property you are setting, are in different appartments. Will it help if you make the call from your event handling sub to another sub as non blocking instead of a blocking call - post the string to a queue or post the reuquest to your UI thread etc
What appartment mode does your main thread run in?
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
I have created a COM based application using DLL server.But i havn't used server as type of EXE.I don't know the exact difference when i will have to use DLL Server or EXE Server with COM base application.
Plase reply me as soon as possible.
Thanks & Regards
Pankaj
Regards,
Pankaj Sachdeva
|
|
|
|
|
DLL-based COM objects will load into the calling application's process. If you implement an EXE server, COM will start your EXE as a separate process. This should be transparent to the calling application. The main difference is that it will take much longer to call code running in another process than code running in your own process.
To actually call code in another process, or another apartment in the same process, COM must marshal the call parameters across the process or apartment boundary. This means writing out all the parameters, and any other areas of memory they reference, to some transport (e.g. a block of shared memory) and somehow signalling the other process that there is a call for it to handle. When the actual function returns, COM must then marshal the results back to the caller. To do this, it has to know the actual data types and whether a pointer represents a string, an array, or just a single object (and if a string or array, how long the string or array is), and whether the parameters are passed in only, passed out only or passed both in and out.
Marshalling can proceed in three ways:
1. The object implements the IMarshal interface;
2. A proxy/stub class is registered for the interface in the registry;
3. A type library is registered to use the Automation marshaller.
Option 3 is really a special case of option 2 - the Automation marshaller is registered as the proxy/stub class. It then looks up the correct type library and uses the information in that to perform the marshalling. This is the most limited option, however. You can only use the Automation data types and structures containing those types. The upside is that scripting languages like VBScript can use your components.
In general, for option 2, you don't actually write your own code for the proxy/stub class. Instead, you define your interfaces in IDL and pass them through the MIDL tool, which generates either tables describing the interfaces or code. The tables have been supported since Windows 98 and Windows NT 4.0, and an update is available for Windows 95 that supports them. All you have to do is build the code into a DLL; Visual Studio generates a project file for you.
COM gets the class factory object for a class implemented in a DLL by calling the DLL's DllGetClassObject function. It cannot call directly into an EXE's code, so the EXE must instead register its class factory objects, for classes that can be created externally, using the CoRegisterClassObject function.
EXE servers are mainly used for implementing OLE and Automation in desktop applications, and where isolation between the client and server is necessary (perhaps for security reasons). If the former, the application typically implements a command-line option (typically /embedding ) to indicate that it was launched by COM, not by the user, and to hide its user interface in response.
Finally, it's possible to make a DLL server run in another process if it's registered as a COM+ Server Application. I'm not sure whether doing this with an arbitrary DLL is a good idea, it is probably best to use a component only how the author intended it to be used (as it is unlikely that they have tested other scenarios).
|
|
|
|
|
I am trying to capture video from web cam.I am using ICaptureGraphBuilder2.
I am getting compilation error
'ICaptureGraphBuilder2' : missing storage-class or type specifiers
'CLSID_CaptureGraphBuilder2' : undeclared identifier
I am using VC6 and visual studio 2003
I have install the directx sdk
I have include the dshow.h
I have included the lib files in project settings.
Quartz.lib Strmiids.lib strmbasd.lib wmvcore.lib wmstub.lib Msvcrtd.libWinmm.lib
I have included the paths in the tools->options->directories
but after doing all this I am getting this compilation error messages. Please any body help me.
S.Yamini
|
|
|
|
|
How to Generate OLE dispatch map functions using class wizard or using any other.
please help.
|
|
|
|
|
Hi all,
Thanx in advance.
|
|
|
|
|
|
1.I am working on win professional xp with regional settings changed to chinese(RPC)
2.I added a custom property in chinese alplabets to a word file from windows explorer.
3.I want to read the Custom Properties of a word file.
4.I got the root storage by StgOpenStorage and finally got the pointer to IPropertyStorage.
5.Now when i read custom property using ReadMultiple, i get invalid characters for the custom Property
6.Note:This happens only for custom properties.
Please let me know the solution of the problem.
Thanks and Regards!
Hands-down one of the best
|
|
|
|
|
Hi, i have an ir receiver connected at serial port. i
want to receive signal at serial port using vb.net. is there any sanple code available or any one who can help me.
Thanks
-Waqas
|
|
|
|
|
This will help[^]
Please do not post same question on multiple forums. Since it's a VB.net question, post only in VB.NET forum.
S o h a i l K a d i w a l a
To Err Is Human; to Debug, Divine
modified 21-Apr-21 21:01pm.
|
|
|
|
|
The question describes as follows:In CxxActiveXCtrl I declare a member m_dlgMain for a dialog which was produce for display the picture and In CxxActiveXCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) function I wrote "m_dlgMain.Create(IDD_MAINDIALOG,this);",then in the dialog's OnInitDialog() procedure I use IPicture to display the specified picture,the display codes is correct,but can see nothing in the html,while move the codes to the dialog's OnDraw() it works ok,I suppose the dialog doesn't notify the control to erease the background but I've written InvalidRect(TRUE) after display.What's the matter?
|
|
|
|
|
why the Exception Retrieving the COM class factory for component with CLSID failed due to the following error: 80004005. occurs how to resolve this.
|
|
|
|
|
Possibly an exception is being thrown from the class constructor. If you have source code for the component, please check the constructor.
S o h a i l K a d i w a l a
To Err Is Human; to Debug, Divine
modified 21-Apr-21 21:01pm.
|
|
|
|
|
I have this same problem did you resolve this issue and how I'd appreciate any feedback.
Thanks in advance,
Michael
|
|
|
|
|