|
WOleApplicationObject *appObject =
WOleApplicationObject::GetOleApplicationObject( );
if (appObject)
{
#ifndef _DEBUG
appObject->SetShowAutomationErrors(false);
#endif
}
Errormessages when building a COM server | Cause |
Missing end of function | The ; is missing after the functiondefinition |
Unexpected word | The ; is missing after the functiondefinition |
Unrecognised type specifier in parameter/return value | You try to use a unsupported type as methodparameter. (*) |
Invalid type | You try to use a unsupported type as methodparameter. (*) |
WByte
// a single byte unsigned
char WShort
// short WInt
// int WUInt
// unsigned int WLong
// long WULong
// unsigned long WDouble
// double WFloat
// floatWChar
// You can also use the WChar
data type, which represents a single character. WChar is defined to
allow for multibyte character sets: character sets where some characters
may be longer than a single byte. (Multibyte characters are required to
support written languages which have a large number of characters in
their alphabets.) WChar also allows for Unicode characters and
double-byte characters. Unicode is used heavily by the OLE facilities.WBStr
// represents a Visual Basic
string type. You must use the WBStr to pass and return arguments, but it
is not convenient to manipulate its string data directly. You should use
the WString, WBuffer and WBString types to manipulate strings in your
methods. When you want to return a string, you simply convert it to a
WBStr and return the WBStr. For simpler handling of all the
WBString/WBStr and WString conversions, you should use the
WAXString class
library.WHRESULT
// is the same as the
Windows type HRESULT. It is a 32-bit value that allows you to specify
whether a method fails, and if so how it fails. Any result code that
begins with S_ indicates that the method succeeded. Result codes
starting with E_ indicate failure.WPIDispatch
// represents a pointer
to an IDispatch interface. IDispatch is the parent class of all
automation interfaces, including the interfaces that you create with
Power++.WPIUnknown
// represents a pointer
to an IUnknown interface. IUnknown is the parent class of all COM
interfaces.WVARIANT_BOOL
// data type
represents a Boolean value. You can use the standard TRUE and FALSE
constants as you would with the WBool class. Strictly speaking, the
value of true for the WVARIANT_BOOL is defined to be -1 (negative one)
and the value of false is 0 (zero). However, any non-zero value is taken
to be true in practice, and zero is taken to be false.Special infos about parameters.
You can pass COM servers as parameters to other com objects. To allow this, the called method must have a parameter of type WPIUnknown.
In P++ you can invoke such a method with the following sequence:
WOleProgrammableObject *_myServer;
WOleProgrammableObject *_myObject;
_myServer= new COMServer;
_myServer->Create(); // This is important, otherwise all methode calls
will fail for no aparent reason.
_myObject= new COMParameter;
_myObject->Create(); // This is important, otherwise all methode calls
will fail for no aparent reason.
WPIDispatch wpiParam= (WPIDispatch )*_myObject;
WVariant wvParam(wpiParam);
retVal= _myServer->CallMethod(&wvParam);
errorInfo = _myServer->GetErrorInfo();
if (errorInfo.error != WInvokeError_None)
{
// Handle errorcondition
}
Remember, this web site is here for you and people
like you. So if you have anything that others might find useful,
let me know, and I'll post it here. E-mail me, André Schild at
a.schild(at)aarboard.ch, or fill
out the form at the bottom of the main
page.
Hope to hear from you soon!
Back to Absolute Power++.