Consultor Eletrônico



Kbase P56328: Sample C++ code to use the ActiveX proxy
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   8/14/2004
Status: Unverified

GOAL:

Sample C++ code to use the ActiveX proxy

FIX:

// Test.cpp : Sample C++ code to use the ActiveX proxy
//
// This sample is not intended to be compiled as is, all references
// to the objects within the proxy must be changed for this code
// to compile successfully

#include "stdafx.h"
#include "iostream.h"
#include "atlbase.h"
// include the header file to Proxy code.
#include "mypath/PROXY.h"

int main(int argc, CHAR* argv[])
{
interface IProxy* pCust = NULL;
HRESULT hr;
hr = CoInitialize (NULL);
if (FAILED(hr)) {
cout << "Failed during initialization " ;
return 0;
}

hr = CoCreateInstance(CLSID_CconObj,
NULL,
CLSCTX_INPROC_SERVER, IID_IPO_myProcedureObj,
(void**)(&pCust));
if (FAILED(hr) || pCust == NULL ) {
cout << "CoCreateInstance() failed \n";
CoUninitialize();
return 0;
}

CComBSTR urlString("AppServer://localhost:5162");
CComBSTR username("");
CComBSTR password("");
CComBSTR appServerInfo("AppServerInfo");

hr = pCust->OC_Connect(urlString, username,password,appServerInfo);
if (FAILED(hr)) {
cout << "Connection to AppServer URL failed.\n";
CoUninitialize();
return 0;
}


IPO_myProcedureObj *CustTT ;
hr = CustTT->internalProcedure1();
if (FAILED(hr)) {
cout << "Failed during the internal procedure execution \n";
CoUninitialize();
return 0;
}

pCust->Release();
CoUninitialize();
return 0;
}