Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing arguments to/from VFP COM server
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01498412
Message ID:
01500279
Vues:
62
Cool! I don't know if you've ever seen this one from Calvin but I've used it successfully before..

C++ Demo:

How much code does it take to create a C++ program that can use the VFP Myserver COM server above? Let’s try it. Start VC, choose File>New> Projects. Type in Mytest as the name of the project, and choose Win32 Application as the project type. Choose File>New>Files>C++ Source file, Add to project, and name it myserver.cpp. Paste the following code:

#include "windows.h"
#import "c:\fox\test\myserver.tlb" //use the full path to the server tlb

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR , int)
{
using namespace myserver; //use the myserver namespace
ImyclassPtr pmyclass; // declare a smart ptr to the server
CoInitialize(0); // initialize COM
pmyclass.CreateInstance("myserver.myclass"); //create an instance
_variant_t myvar, vresult; // declare 2 variant variables.
_bstr_t res; // declare a bstr variable
myvar = "version(1)"; // assign the variable
vresult = pmyclass->myeval(&myvar); //invoke the method
res = vresult.bstrVal; // get the Unicode result
MessageBox(0,(char *)res,"",0); //show it
pmyclass = 0; // release the server
CoUninitialize(); //uninitialize COM
return 0;
}
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform