|
First time posting....let's begin
I have spent the last 2 days searching the net for examples\explaination for SAFEARRAY as a mean of transferring data. This is the problem:
Client: MFC
Server: ATL COM EXE
I would like the client to give the server an SQL command, and the server to execute it.
ExecuteSQL ([in] BSTR bsSQL,........)
Very straight forward for commands such as:
"Delete from tblMyTable <where clause="">,,,,"
"Insert into tblMyTable VALUES (,,,,,)" ->you get what i mean.
However, i want the server to be able to execute commands such as
"Select * from tblMyTable". This is where a second parameter comes into the function
ExecuteSQL ([in]BSTR bsSQL, [out] VARIANT * Var,..)
I have read and re-read about safearrays, but the samples i c are good for cases where i know the size of the data i have.
Let's ASSUME (i only know this at run time) that I have a recordset of 5 columns (Fields) and 6 rows (any numbers would do as long as it is greater than 2!!!).
Can someone pls explain to me how I construct the safearray??? (PLEASE). I tried a certain method, and it seemed to work to the point where i get back to the client and on attemtping to get elements receive an "invalid index".
What i thought of doing is:
1) Declare an array of NumRows SAFEARRAYBOUND(s)
2) Each arraybound has NumFields elements (so in my case i get a 6x5 array)
3) Call SafeArrayCreate with VT_VARIANT, NumRows and the array of
safearraybounds.
4) I set the variant's type to be VT_VARIANT | VT_ARRAY
5) I declare a long Dimension[2] array to help me place the values I read
from the recordset into the 6x5 Variant array
6) I use two "for" loops to iterate through the rowsets and their fields
for (RowIndex (0);RowIndex<rowcount &&="" !rs.iseof()="" ;rowindex++)
{
="" for="" (fieldindex(0);fieldindex="" <="" fieldcount;="" fieldindex++)
="" {
="" ccomvariant="" var;
="" var="rs.Field(FieldIndex);
" dimension[1]="FieldIndex;
" dimension[0]="RowIndex;"
="" safearrayputelement(psafearr-="">parray, lDimension,&Var);
}
rs.MoveNext();
}
7) This copies all the data into the array.
8) I return to the client, get the safearray from the VARIANT, get the dims
param (yes, it is 6 <smile>) and lower(0)\upper (4) bound.
9) I declare again Dimension[2] in the client, and attempt to read the
first element (0,0) from the safearray using SafeArrayGetElement,
and......"invalid index"
10) * What am i doing wrong??
* I am using an IUnknown for the interface and define oleautomation in
the idl), will IDispatch make any difference (tried,but maybe forgot
something)
|
|
|
|
|
Hi,
I am trying to implement an edit host (IHTMLEditHost).
According to the msdn documentation the host of the browser control has to implement the IServiceProvider.
What is the Host? The CHtmlView class?
I looked at the ATL example (EditHost.exe at msdn), and tried to implement the
IServiceProvider interface in the CHtmlView class. But this doesn't work.
The interface function QueryService is not called after
activating the editor (spDoc->put_designmode(L"On").
Does anyone have any idea how to do this?
Thanks,
Jurgen Wolke
.
|
|
|
|
|
Hi,
I'm trying to get info out of a typelib at runtime, using the ITypeLib interface returned from a GetTypeLib(...) call. I'm having trouble with the enums in the typelib. I'd like to be able to get the names of members of the enum and their helpstrings at run time from the ITypeInfo interface for the enum. I can get the name of the enum itself, but can't get anything inside of it. Here's the code I'm tryin to use:
ITypeLib* pTypeLib = NULL;
ITypeInfo* pTypeInfo = NULL;
hr = LoadTypeLib(path, &pTypeLib);
if(SUCCEEDED(hr))
{
// Get info about the typelib itself
BSTR bstrName, bstrDocString, bstrHelpFile;
DWORD dwHelpContext;
pTypeLib->GetDocumentation(-1, &bstrName, &bstrDocString, &dwHelpContext, &bstrHelpFile);
name = bstrName;
docString = bstrDocString;
helpFile = bstrHelpFile;
fprintf(log, "\n--TypeLib information for <%s> -- ", (char*)path);
fprintf(log, "\nName: %s", (char*)name);
fprintf(log, "\nDocString: %s", (char*)docString);
fprintf(log, "\nHelpFile: %s", (char*)helpFile);
fprintf(log, "\n\n");
SysFreeString(bstrName);
SysFreeString(bstrDocString);
SysFreeString(bstrHelpFile);
UINT count = pTypeLib->GetTypeInfoCount();
for(int i = 0; i < count; i++)
{
hr = pTypeLib->GetTypeInfo(i, &pTypeInfo);
if(SUCCEEDED(hr))
{
// Examine the type info for this thingy
// Get documentation about the interface/struct/etc
pTypeInfo->GetDocumentation(-1, &bstrName, &bstrDocString, &dwHelpContext, &bstrHelpFile);
name = bstrName;
docString = bstrDocString;
helpFile = bstrHelpFile;
fprintf(log, "\n--TypeLib information for typelib member # <%i> -- ", i);
fprintf(log, "\nName: %s", (char*)name);
fprintf(log, "\nDocString: %s", (char*)docString);
fprintf(log, "\nHelpFile: %s", (char*)helpFile);
// Type attributes
TYPEATTR* pTypeAttr = NULL;
pTypeInfo->GetTypeAttr(&pTypeAttr);
int j = 0;
switch(pTypeAttr->typekind)
{
case TKIND_COCLASS: fprintf(log, "\ntypekind = TKIND_COCLASS");
break;
case TKIND_ALIAS: fprintf(log, "\ntypekind = TKIND_ALIAS");
break;
case TKIND_DISPATCH: fprintf(log, "\ntypekind = TKIND_DISPATCH");
fprintf(log, "\ncFuncs = %i", pTypeAttr->cFuncs);
while(j < pTypeAttr->cFuncs)
{
pTypeInfo->GetDocumentation(j, &bstrName, &bstrDocString, &dwHelpContext, &bstrHelpFile);
name = bstrName;
docString = bstrDocString;
helpFile = bstrHelpFile;
fprintf(log, "\n--TypeLib information for typelib submember # <%i> -- ", j);
fprintf(log, "\nName: %s", (char*)name);
fprintf(log, "\nDocString: %s", (char*)docString);
fprintf(log, "\nHelpFile: %s", (char*)helpFile);
// Release strings and stuff
SysFreeString(bstrName);
SysFreeString(bstrDocString);
SysFreeString(bstrHelpFile);
j++;
}
break;
case TKIND_ENUM: fprintf(log, "\ntypekind = TKIND_ENUM");
fprintf(log, "\ncVars = %i", pTypeAttr->cVars);
// Enumerate the constants and get doc.
while(j < pTypeAttr->cVars)
{
// ***This next line fails***
hr = pTypeInfo->GetDocumentation(j, &bstrName, &bstrDocString, &dwHelpContext, &bstrHelpFile);
name = bstrName;
docString = bstrDocString;
helpFile = bstrHelpFile;
fprintf(log, "\n--TypeLib information for enum submember # <%i> -- ", j);
fprintf(log, "\nName: %s", (char*)name);
fprintf(log, "\nDocString: %s", (char*)docString);
fprintf(log, "\nHelpFile: %s", (char*)helpFile);
// Release strings and stuff
SysFreeString(bstrName);
SysFreeString(bstrDocString);
SysFreeString(bstrHelpFile);
j++;
}
break;
case TKIND_INTERFACE: fprintf(log, "\ntypekind = TKIND_INTERFACE");
break;
case TKIND_MAX: fprintf(log, "\ntypekind = TKIND_MAX");
break;
case TKIND_MODULE: fprintf(log, "\ntypekind = TKIND_MODULE");
break;
case TKIND_RECORD: fprintf(log, "\ntypekind = TKIND_RECORD");
break;
case TKIND_UNION: fprintf(log, "\ntypekind = TKIND_UNION");
break;
default:
fprintf(log, "\nUnrecognized type kind.");
}
pTypeInfo->ReleaseTypeAttr(pTypeAttr);
// Release strings and stuff
SysFreeString(bstrName);
SysFreeString(bstrDocString);
SysFreeString(bstrHelpFile);
pTypeInfo->Release();
fprintf(log, "\n\n");
}
}
And here is the declaration of the enum (from a larger typelib) that I am trying to get some info about:
// Options for calculating roughness correction factor for PSW [helpstring("Roughness Correction Factor Calculation Options") ]
typedef enum
{
[ helpstring("No roughness correction applied") ]
ROUGHNESS_NONE,
[ helpstring("Viscosity based correction factor") ]
ROUGHNESS_VISCOSITY,
[ helpstring("Reynold's number based correction factor") ]
ROUGHNESS_REYNOLDS
} RoughnessCFOption;
I am getting a failure on the call to get documentation for each of the members of the struct. So maybe I should be usin a different call here?
Thanks in advance for any help.
Aaron
|
|
|
|
|
Seems I've answered my own question.
The offending section revised now seems to be working:
case TKIND_ENUM: fprintf(log, "\ntypekind = TKIND_ENUM");
fprintf(log, "\ncVars = %i", pTypeAttr->cVars);
// Enumerate the constants and get doc.
while(j < pTypeAttr->cVars)
{
hr = pTypeInfo->GetVarDesc(j, &pVarDesc);
hr = pTypeInfo->GetDocumentation(pVarDesc->memid, &bstrName, &bstrDocString, &dwHelpContext, &bstrHelpFile);
pTypeInfo->ReleaseVarDesc(pVarDesc);
name = bstrName;
docString = bstrDocString;
helpFile = bstrHelpFile;
fprintf(log, "\n--TypeLib information for enum submember # <%i> -- ", j);
fprintf(log, "\nName: %s", (char*)name);
fprintf(log, "\nDocString: %s", (char*)docString);
fprintf(log, "\nHelpFile: %s", (char*)helpFile);
// Release strings and stuff
SysFreeString(bstrName);
SysFreeString(bstrDocString);
SysFreeString(bstrHelpFile);
j++;
}
break;
|
|
|
|
|
My class is from the Lite Control wizard. I am trying to do some clipboard stuff so I would like to set up a timer to periodiacally poll the clipboard. I have added a WM_CREATE handler to set up the timer but it never seems to get called.
Therefore, I tried moving the timer code into the constructor and FinalConstruct() and in both places, I get an ASSERT because m_hWnd is not set up. Now, I know that CComControl derives from CWindowImpl which derives from CWindow and sure enough there is an m_hWnd member there. The debugger says it is unused.
I don't want to create a dummy window with a separate message map just to have a timer or be inserted into the clipboard chain, however I can't get the m_hWnd member to be valid. Do I have to inherit the container's property or something? Has anyone here done this before?
-pos
|
|
|
|
|
I'm going to reply to my own thread again.
I turns out that WM_CREATE doesn't get called because the m_hwnd member is not a real window. When you create the project, just select "windowed only" and your component will only work in windowed containers. but wil in fact work
-pos
|
|
|
|
|
Hay
reading a lot about shell extentions, i still didn't find a way to extend Explorer by "catching" file selection (LEFT click on a file ) and do something in response to it.
any ideas how to do it?
(ho, and FileManager Extentions are only for Win3.11 ?)
|
|
|
|
|
I am writing a function that need to return a variant data type ,some times string sometimes integral and so on.so I declare a variale with a VARIANT data type but I chocked when I know that I must determine wich type of variant before I use it(VT_U8,VT_I and ...).
I thought it is like a Variant type in Visual Basic.
So can any body tell me how can do that.
M.S.
|
|
|
|
|
use this variant crack.. This is gives you an idea of how to use a variant
CString CLeftView::CrackStrVariant(const COleVariant& var)
{
CString strRet;
strRet = _T("<Unknown>");
switch(var.vt)
{
case VT_EMPTY:
case VT_NULL:
strRet = _T("NULL");
break;
case VT_I2:
strRet.Format(_T("%hd"), V_I2(&var));
break;
case VT_I4:
strRet.Format(_T("%d"),V_I4(&var));
break;
case VT_R4:
strRet.Format(_T("%e"), (double)V_R4(&var));
break;
case VT_R8:
strRet.Format(_T("%e"), V_R8(&var));
break;
case VT_CY:
strRet = COleCurrency(var).Format();
break;
case VT_DATE:
strRet = COleDateTime(var).Format(_T("%c"));
break;
case VT_BSTR:
strRet = V_BSTR(&var);
break;
case VT_DISPATCH:
strRet = _T("VT_DISPATCH");
break;
case VT_ERROR:
strRet = _T("VT_ERROR");
break;
case VT_BOOL:
return ( V_BOOL(&var) ? _T("TRUE") : _T("FALSE"));
case VT_VARIANT:
strRet = _T("VT_VARIANT");
break;
case VT_UNKNOWN:
strRet = _T("VT_UNKNOWN");
break;
case VT_I1:
strRet = _T("VT_I1");
break;
case VT_UI1:
strRet.Format(_T("0x%02hX"), (unsigned short)V_UI1(&var));
break;
case VT_UI2:
strRet = _T("VT_UI2");
break;
case VT_UI4:
strRet = _T("VT_UI4");
break;
case VT_I8:
strRet = _T("VT_I8");
break;
case VT_UI8:
strRet = _T("VT_UI8");
break;
case VT_INT:
strRet = _T("VT_INT");
break;
case VT_UINT:
strRet = _T("VT_UINT");
break;
case VT_VOID:
strRet = _T("VT_VOID");
break;
case VT_HRESULT:
strRet = _T("VT_HRESULT");
break;
case VT_PTR:
strRet = _T("VT_PTR");
break;
case VT_SAFEARRAY:
strRet = _T("VT_SAFEARRAY");
break;
case VT_CARRAY:
strRet = _T("VT_CARRAY");
break;
case VT_USERDEFINED:
strRet = _T("VT_USERDEFINED");
break;
case VT_LPSTR:
strRet = _T("VT_LPSTR");
break;
case VT_LPWSTR:
strRet = _T("VT_LPWSTR");
break;
case VT_FILETIME:
strRet = _T("VT_FILETIME");
break;
case VT_BLOB:
strRet = _T("VT_BLOB");
break;
case VT_STREAM:
strRet = _T("VT_STREAM");
break;
case VT_STORAGE:
strRet = _T("VT_STORAGE");
break;
case VT_STREAMED_OBJECT:
strRet = _T("VT_STREAMED_OBJECT");
break;
case VT_STORED_OBJECT:
strRet = _T("VT_STORED_OBJECT");
break;
case VT_BLOB_OBJECT:
strRet = _T("VT_BLOB_OBJECT");
break;
case VT_CF:
strRet = _T("VT_CF");
break;
case VT_CLSID:
strRet = _T("VT_CLSID");
break;
}
WORD vt = var.vt;
if(vt & VT_ARRAY)
{
vt = vt & ~VT_ARRAY;
strRet = _T("Array of ");
}
if(vt & VT_BYREF)
{
vt = vt & ~VT_BYREF;
strRet += _T("Pointer to ");
}
if(vt != var.vt)
{
switch(vt)
{
case VT_EMPTY:
strRet += _T("VT_EMPTY");
break;
case VT_NULL:
strRet += _T("VT_NULL");
break;
case VT_I2:
strRet += _T("VT_I2");
break;
case VT_I4:
strRet += _T("VT_I4");
break;
case VT_R4:
strRet += _T("VT_R4");
break;
case VT_R8:
strRet += _T("VT_R8");
break;
case VT_CY:
strRet += _T("VT_CY");
break;
case VT_DATE:
strRet += _T("VT_DATE");
break;
case VT_BSTR:
strRet += _T("VT_BSTR");
break;
case VT_DISPATCH:
strRet += _T("VT_DISPATCH");
break;
case VT_ERROR:
strRet += _T("VT_ERROR");
break;
case VT_BOOL:
strRet += _T("VT_BOOL");
break;
case VT_VARIANT:
strRet += _T("VT_VARIANT");
break;
case VT_UNKNOWN:
strRet += _T("VT_UNKNOWN");
break;
case VT_I1:
strRet += _T("VT_I1");
break;
case VT_UI1:
strRet += _T("VT_UI1");
break;
case VT_UI2:
strRet += _T("VT_UI2");
break;
case VT_UI4:
strRet += _T("VT_UI4");
break;
case VT_I8:
strRet += _T("VT_I8");
break;
case VT_UI8:
strRet += _T("VT_UI8");
break;
case VT_INT:
strRet += _T("VT_INT");
break;
case VT_UINT:
strRet += _T("VT_UINT");
break;
case VT_VOID:
strRet += _T("VT_VOID");
break;
case VT_HRESULT:
strRet += _T("VT_HRESULT");
break;
case VT_PTR:
strRet += _T("VT_PTR");
break;
case VT_SAFEARRAY:
strRet += _T("VT_SAFEARRAY");
break;
case VT_CARRAY:
strRet += _T("VT_CARRAY");
break;
case VT_USERDEFINED:
strRet += _T("VT_USERDEFINED");
break;
case VT_LPSTR:
strRet += _T("VT_LPSTR");
break;
case VT_LPWSTR:
strRet += _T("VT_LPWSTR");
break;
case VT_FILETIME:
strRet += _T("VT_FILETIME");
break;
case VT_BLOB:
strRet += _T("VT_BLOB");
break;
case VT_STREAM:
strRet += _T("VT_STREAM");
break;
case VT_STORAGE:
strRet += _T("VT_STORAGE");
break;
case VT_STREAMED_OBJECT:
strRet += _T("VT_STREAMED_OBJECT");
break;
case VT_STORED_OBJECT:
strRet += _T("VT_STORED_OBJECT");
break;
case VT_BLOB_OBJECT:
strRet += _T("VT_BLOB_OBJECT");
break;
case VT_CF:
strRet += _T("VT_CF");
break;
case VT_CLSID:
strRet += _T("VT_CLSID");
break;
}
}
return strRet;
}
|
|
|
|
|
Maybe the helper classes CComVariant & _variant_ can help you ? I don't know if I understand your question correct ? Is this an answer to your question ?
-Nick-
|
|
|
|
|
This piece of code works when i instantiate an object as 'inproc':
MULTI_QI qi[2] = {0};
qi[0].pIID = &IID_IAgentCore;
qi[1].pIID = &IID_IConnectionPointContainer;
hr = CoCreateInstanceEx(
CLSID_AgentCore, NULL,
server_type, pServerInfo,
2, qi);
IConnectionPointContainerPtr pCPC_AgentCore;
...
pCPC_AgentCore = (IConnectionPointContainer*)qi[1].pItf;
...
hr = pCPC_AgentCore->FindConnectionPoint(IID__IAgentCoreEventsFlat, &m_pCoreEvents);
if ( SUCCEEDED( hr ) )
{
hr = m_pCoreEvents->Advise(GetUnknown(), &m_CoreCookie);
if ( FAILED( hr ) )
throw hr;
}
else
throw hr;
but when the object AgentCore is on the remote computer Advise() failes with 'Access denied' error. Note that object is created and other method calls were successful. So i dont think it is a security problem...
IAgentCoreEventsFlat is an ordinary interface inherited from IUnknown. I'm launching a DLL with the help of DLLHOST.EXE on remote machine.
Please help!
Thanks.
|
|
|
|
|
The only way we got this to work was to set the default security in DCOMCNFG to NONE. It appears that the operating system only allows you set up security on calls to the server/service, so they will work, and not from the server to the client which will fail with an Access denied error.
|
|
|
|
|
See COM Security Article by Jeff Prosise at
http://www.codeguru.com/activex/COMSecurity1.html
Especially the section worded
Power COM Programming Tip
Well Worth a read
|
|
|
|
|
I am developping a COM DLL project using VC++ ,I need to use some VB ActiveX dll functions in my project,one of these function take an enum type lets called 'SomeEnum' as a parameter so when declare the same enum type in the VC++ and pass it to a vb function I have got an error like this:
"cannot convert parameter 1 from 'enum MyC++Class::SomeEnum to 'enum VBClass::SomeEnum ".
please Can any body help me?!
|
|
|
|
|
Hi,
My component is just a simple ATL component,which supports outgoing interfaces.Component is interacting with Host which is situated on other machine ,whenever message comes from the host to my component ,my component will fire event which must be trapped by front end ,which is web page , scripting language is VB script.
Like in VB i have withevents to trap evets from component ,how should i do it in VBscript? Do i need to change the component for that?
If anyone can suggest it will be helpfull to me.
Thank u
|
|
|
|
|
Hi, I've been having a hard time deciding which methods to use in C++ to access COM objects when performance is an issue. When I don't care about performance I use a ClassWizard generated MFC class that uses CString istead of those annoying BSTRs!, but when I care about performance I see the following options:
1. Straight C++ which is not very readable
2. #import -> SmartPointers
3. ATL's CComPtr
...
What are the performance hits by not choosing #1?
What are the tradeoffs between 2 and 3?
And finally, how much does IDispatch support hurt C++ performance (for the sake of exposing access to scripting languages)? Do real-world developers ever use IDispatch for testing in VB and then use an IUnknown for a VC++ client for the sake of performance?
Thanks!
Mach5 Enterprises, LLC. http://www.mach5.com/
"Web Intelligence for the New Economy"
|
|
|
|
|
What is the different between Windows COM Service and Windows device Driver?
Can Windows Device Driver call Windows COM Service or Local COM Server?
Thank you very much,
BD
|
|
|
|
|
I have an ATL project that acts as a plugin to a 3rd party application. The first method (as seen in oleview) works fine . The 2nd and subsequent methods never get called
Any suggestions?
Thanks
|
|
|
|
|
Ok, last time i answered my own question: http://www.codeproject.com/script/comments/forums.asp?forumid=1648&exp=0&select=45309#xx45309xx
(I'm still waiting for some guru to tell me if there is a way to do that in Netscape)
Lets see if I beat you all to it this time:
I just created the ATL dialog based control using the VC Wizard. I added an edit field using the dialog editor and now I want my program to set the text in it. I get an ASSERT when I make a call to GetDlgItem(IDC_EDIT). What is the correct way to do this.
I see lots of tutorials showing how to open a new dialog from ATL but none on how to access the controls you drop on the dialog that the ATL project is derived from using the wizard.
Thanks in advance to anyone who can help.
-pos
|
|
|
|
|
The approach I've used is to gt the controls interface, and access it through that. You might try something like the following. Call CWindow::GetDlgControl(...), which will give you an interface to the control. Query for the specific interface you're interested in. Register for any events the control fires that you are interested in. You'll have to #import the type lib for the control somewhere, so the interfaces will be available to you. Once you have the interface, use it like any other COM object. Be sure to release everything and unadvise when you're done with it.
Good luck!
HRESULT Connect(T* pParent)
{
HRESULT hr;
// Get the control's interface
m_pParent = pParent;
hr = m_pParent->GetDlgControl(ControlID, IID_IUnknown, (void**)&m_pUnkCtrl);
if(FAILED(hr)) return hr;
// TEST Section
HEdit::_DHEditDouble* pHEdit;
hr = m_pUnkCtrl->QueryInterface(HEdit::DIID__DHEditDouble, (void**)&pHEdit);
if(SUCCEEDED(hr))
{
pHEdit->Release();
}
// Advise the control
hr = IDispEventSimpleImpl<1, ATLHEditWrapper, &HEdit::DIID__DHEditDoubleEvents>::DispEventAdvise(m_pUnkCtrl);
return hr;
}
|
|
|
|
|
Hi, I'm calling an MFC/ATL COM dll from inside IE using javascript and using the "OBJECT" tag. If my MFC code ASSERTs I can't seem to do anything other than rebooting to unlock that DLL (i.e. I can't fix a bug and recompile). Is there any way to force Win98 to release the COM dll? If I call the object from a VC++ exe and "Abort" the ASSERT everything works fine, but IE seems to hold the DLL even after I ABORT|RETRY|IGNORE. Thanks!
Mach5 Enterprises, LLC. http://www.mach5.com/
"Web Intelligence for the New Economy"
|
|
|
|
|
How do i put map in DISPPARAMS structure
i tried
typedef std::map<char*,int>commandMap;
commandMap cmdMap;
VARIANT vars[1];
VariantInit(&vars [0]);
vars[0].vt=VT_BYREF;
vars[0].byref=static_cast<void*>(cmdMap);
what is the mistake in this ?
parag
|
|
|
|
|
I have been asked to inhance performance for some project written in VB,actually this project contain many sub projects (ActiveX dlls)one of these dll need to be a multithreded so it convert some part of it to COM dll C++ I did not want to convert allthis dll so I tried to use it in my VC so I tried to put it in a separate VB Activex dll to use it in my VC project,
the problem is when I tried to import a VB dll in my VC project like this:
#import "VBDLL.dll"
#import "another.dll"
I have got many errors in the "VBDLL.tlh" it seems that the compiler can not recognize for some objects in it,and when I swap the import dll like this:
#import "another.dll"
#import "VBDLL.dll"
the errors will become less than before.
Can anybody help me.
|
|
|
|
|
You can use the following VB Script to create a project:
Set objMSDEV = WScript.CreateObject("msdev.application")
objMSDEV.addproject "test","c:\myapp",TRUE
objMSDEV.ActiveProject.AddFile "test.cpp"objMSDEV.QuitWScript.Echo "Done"
From this I have determined that the following C++ code should also generate a project:
#include "stdafx.h"
#include <stdio.h>
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>
#include <initguid.h>
#include <comdef.h>
#include <ObjModel\appauto.h>
#include <ObjModel\appdefs.h>
#include <ObjModel\appguid.h>
#include <ObjModel\bldauto.h>
#include <ObjModel\bldguid.h>
#include <ObjModel\blddefs.h>
#include <ObjModel\textauto.h>
#include <ObjModel\textguid.h>
#include <ObjModel\textdefs.h>
#include <ObjModel\dbgauto.h>
#include <ObjModel\dbgguid.h>
#include <ObjModel\dbgdefs.h>
IApplication *pApp;
int main(int argc, char* argv[])
{
HRESULT hr = CoInitialize(NULL);
if(FAILED(hr))
{
printf("Failed to initialize the COM libraries\n");
return FALSE;
}
hr = CoCreateInstance(CLSID_Application, NULL, CLSCTX_LOCAL_SERVER, IID_IApplication, (void**)&pApp);
if(FAILED(hr))
{
printf("Failed to create an instance of MSDEV\n");
CoUninitialize();
}
CComBSTR bProjectName("project");
CComBSTR bPath("c:\\myproject");
CComBSTR bType("Application");
VARIANT_BOOL bCreateDirs=VARIANT_FALSE;
pApp->AddProject(bProjectName,bPath,bType,bCreateDirs);
pApp->Quit();
pApp=NULL;
CoUninitialize();
return 0;
}
The problem is the call to add the project generates the following error:
Debug Error!
Program: test.exe
Module:
File: i386\chkesp.c
Line: 42
The value of ESP was not properly saved accross a function call.
This is usually a result of calling a function declared with one
calling convention with a function pointer declared with a different
calling convention.
Can any body tell me what I am doing wrong?
Thanks for any help you can provide.
Steve.
|
|
|
|
|
If the anybody, who know's how I can extend the context-menu ( right mouse click over a link) from the IE5 with a functions of my own EXE/DLL Library ?
( i.e like the WebWasher)
...yks
|
|
|
|
|