次の方法で共有


Referencing Data Types in COM Objects

When you use Visual FoxPro as an early binding client and want to reference a variant data type in a COM object, you must first create an instance of the variable with the type you expect to retrieve. For example:

DEFINE CLASS varianttest AS SESSION OLEPUBLIC
   FUNCTION varret(outVal AS VARIANT@, inVal AS VARIANT) AS VOID
      OutVal = inVal
   ENDFUNC
ENDDEFINE

After building this class into a DLL named myServer, you can reference the data as shown in the following code:

x = CREATEOBJECT("myServer.varianttest","","")
ov = ""
tt.varret(@ov, "string")   && Sets string value.
ov = 0
tt.varret(@ov, 123)         && Sets ov to an integer value.
ov = 0.0
tt.varret(@ov, 44.44)      && Sets ov to a real numeric value.
ov = l
tt.varret(@ov, f)            && Sets ov to a Boolean value.

See Also

Reference

Binding Type Libraries

Early (vtable) and Late (IDispatch) Binding

Other Resources

Working with Automation Servers