General information
Category:
Coding, syntax & commands
Hi
We are having some problem maybe you can help us again. We use microsoft VISUAL C++ version 6 and we have the following error about ImyclassPtr when we try to compile the code.
/*
D:\CPP\testmichel\testmichel.cpp(28) : error C2065: 'ImyclassPtr' : undeclared identifier
D:\CPP\testmichel\testmichel.cpp(28) : error C2146: syntax error : missing ';' before identifier 'pmyclass'
D:\CPP\testmichel\testmichel.cpp(28) : error C2065: 'pmyclass' : undeclared identifier
D:\CPP\testmichel\testmichel.cpp(30) : error C2228: left of '.CreateInstance' must have class/struct/union type
D:\CPP\testmichel\testmichel.cpp(34) : error C2227: left of '->myeval' must point to class/struct/union
*/
Our code
/*#include "windows.h"*/
#import "d:\temp\test.tlb" //use the full path to the server tlb
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
using namespace test; //use the myserver namespace
ImyclassPtr pmyclass; // declare a smart ptr to the server
CoInitialize(0); // initialize COM
pmyclass.CreateInstance("test.test"); //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(); //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;
}
Thanks
Michel
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only