|
And this has what connection to ATL/WTL/STL?
|
|
|
|
|
whats the advantage in using CComPtr over CComQIPtr?
How to create COM object using CComObject class?
|
|
|
|
|
CComQIPtr performs an IUnknown->QueryInterface call on the interface pointer you pass in the constructor, to get a correctly typed interface pointer (or NULL in the case that the interface pointer you gave it does not implement the interface pointer type you want). CComPtr assumes that you're passing a correctly typed interface pointer (i.e. the same type as what the CComPtr has been instantiated for).
So - if you are 100% sure that the interface pointer type is the correct type, CComPtr is fine. If you can't make that guarantee, then you need to use CComQIPtr . CComQIPtr 's constructor will be a little slower than CComPtr 's (it does the QueryInterface call, after all), but it is safe.
|
|
|
|
|
I am using Vista and VS2008. I have changed setup80.js and it gives the message
App Wizard successfully installed!
Now when I want to create a project it goes through all the dialog boxes but at the end no project is created. What I am missing.
|
|
|
|
|
Yesterday I installed VS2008, downloaded WTL and added the WTL include directory to VS settings but had not run the .js file. So after seeing you mail I tried it only to have it say it couldn't find Visual Studio. You said you changed setup80.js; but not what you changed which would have helped. Anyway, a quick look in the registry showed that it 9.0 was needed, presumably this is what you meant. I did a search and replace in setup80.js for '8.0' and changed it to '9.0' in about four places. I saved the file as setup90.js and ran it with it completing successfuly.
On starting a new VS2008 project I now get the option of a WTL project. Selecting this and the defaults on the wizard gave me a WTL project, files and all.
I realise this doesn't tell you what you are doing wrong, but it does tell you what I did to get it to work.
|
|
|
|
|
Nice post. I have not yet used WTL in VS2008 so this information will be great when I do, thanks.
led mike
|
|
|
|
|
I did not change anything in registry but changed js file.
// Windows Template Library - WTL version 8.0
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// This file is a part of the Windows Template Library.
// The use and distribution terms for this software are covered by the
// Microsoft Permissive License (Ms-PL) which can be found in the file
// Ms-PL.txt at the root of this distribution.
// Setup program for the WTL App Wizard for VC++ 8.0 (Whidbey)
main();
function main()
{
// Decode command line arguments
var bDebug = false;
var bElevated = false;
var Args = WScript.Arguments;
for(var i = 0; i < Args.length; i++)
{
if(Args(i) == "/debug")
bDebug = true;
else if(Args(i) == "/elevated")
bElevated = true;
}
// See if UAC is enabled
var Shell = WScript.CreateObject("Shell.Application");
if(!bElevated && Shell.IsRestricted("System", "EnableLUA"))
{
// Check that the script is being run interactively.
if(!WScript.Interactive)
{
WScript.Echo("ERROR: Elevation required.");
return;
}
// Now relaunch the script, using the "RunAs" verb to elevate
var strParams = "\"" + WScript.ScriptFullName + "\"";
if (bDebug)
strParams += " /debug";
strParams += " /elevated";
Shell.ShellExecute(WScript.FullName, strParams, null, "RunAs");
return;
}
// Create shell object
var WSShell = WScript.CreateObject("WScript.Shell");
// Create file system object
var FileSys = WScript.CreateObject("Scripting.FileSystemObject");
// Get the folder containing the script file
var strValue = FileSys.GetParentFolderName(WScript.ScriptFullName);
if(strValue == null || strValue == "")
strValue = ".";
var strSourceFolder = FileSys.BuildPath(strValue, "Files");
if(bDebug)
WScript.Echo("Source: " + strSourceFolder);
if(!FileSys.FolderExists(strSourceFolder))
{
WScript.Echo("ERROR: Cannot find Wizard folder (should be: " + strSourceFolder + ")");
return;
}
try
{
//var strVC8Key = "HKLM\\Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir";
var strVC8Key = "HKLM\\SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VC\\ProductDir";
strValue = WSShell.RegRead(strVC8Key);
}
catch(e)
{
try
{
var strVC8Key_x64 = "HKLM\\Software\\Wow6432Node\\Microsoft\\VisualStudio\\9.0\\Setup\\VC\\ProductDir";
strValue = WSShell.RegRead(strVC8Key_x64);
}
catch(e)
{
WScript.Echo("ERROR: Cannot find where Visual Studio 9.0 is installed.");
return;
}
}
var strDestFolder = FileSys.BuildPath(strValue, "vcprojects");
if(bDebug)
WScript.Echo("Destination: " + strDestFolder);
if(!FileSys.FolderExists(strDestFolder))
{
WScript.Echo("ERROR: Cannot find destination folder (should be: " + strDestFolder + ")");
return;
}
// Copy files
try
{
var strSrc = FileSys.BuildPath(strSourceFolder, "WTLAppWiz.ico");
var strDest = FileSys.BuildPath(strDestFolder, "WTLAppWiz.ico");
FileSys.CopyFile(strSrc, strDest);
strSrc = FileSys.BuildPath(strSourceFolder, "WTLAppWiz.vsdir");
strDest = FileSys.BuildPath(strDestFolder, "WTLAppWiz.vsdir");
FileSys.CopyFile(strSrc, strDest);
}
catch(e)
{
var strError = "no info";
if(e.description.length != 0)
strError = e.description;
WScript.Echo("ERROR: Cannot copy file (" + strError + ")");
return;
}
// Read and write WTLAppWiz.vsz, add engine version and replace path when found
try
{
var strSrc = FileSys.BuildPath(strSourceFolder, "WTLAppWiz.vsz");
var strDest = FileSys.BuildPath(strDestFolder, "WTLAppWiz.vsz");
var ForReading = 1;
var fileSrc = FileSys.OpenTextFile(strSrc, ForReading);
if(fileSrc == null)
{
WScript.Echo("ERROR: Cannot open source file " + strSrc);
return;
}
var ForWriting = 2;
var fileDest = FileSys.OpenTextFile(strDest, ForWriting, true);
if(fileDest == null)
{
WScript.Echo("ERROR: Cannot open destination file" + strDest);
return;
}
while(!fileSrc.AtEndOfStream)
{
var strLine = fileSrc.ReadLine();
if(strLine.indexOf("Wizard=VsWizard.VsWizardEngine") != -1)
strLine += ".8.0";
else if(strLine.indexOf("WIZARD_VERSION") != -1)
strLine = "Param=\"WIZARD_VERSION = 8.0\"";
else if(strLine.indexOf("ABSOLUTE_PATH") != -1)
strLine = "Param=\"ABSOLUTE_PATH = " + strSourceFolder + "\"";
fileDest.WriteLine(strLine);
}
fileSrc.Close();
fileDest.Close();
}
catch(e)
{
var strError = "no info";
if(e.description.length != 0)
strError = e.description;
WScript.Echo("ERROR: Cannot read and write WTLAppWiz.vsz (" + strError + ")");
return;
}
// Create WTL folder
var strDestWTLFolder = "";
try
{
strDestWTLFolder = FileSys.BuildPath(strDestFolder, "WTL");
if(!FileSys.FolderExists(strDestWTLFolder))
FileSys.CreateFolder(strDestWTLFolder);
if(bDebug)
WScript.Echo("WTL Folder: " + strDestWTLFolder);
}
catch(e)
{
var strError = "no info";
if(e.description.length != 0)
strError = e.description;
WScript.Echo("ERROR: Cannot create WTL folder (" + strError + ")");
return;
}
// Read and write additional WTLAppWiz.vsdir, add path to the wizard location
try
{
var strSrc = FileSys.BuildPath(strSourceFolder, "WTLAppWiz.vsdir");
var strDest = FileSys.BuildPath(strDestWTLFolder, "WTLAppWiz.vsdir");
var ForReading = 1;
var fileSrc = FileSys.OpenTextFile(strSrc, ForReading);
if(fileSrc == null)
{
WScript.Echo("ERROR: Cannot open source file " + strSrc);
return;
}
var ForWriting = 2;
var fileDest = FileSys.OpenTextFile(strDest, ForWriting, true);
if(fileDest == null)
{
WScript.Echo("ERROR: Cannot open destination file" + strDest);
return;
}
while(!fileSrc.AtEndOfStream)
{
var strLine = fileSrc.ReadLine();
if(strLine.indexOf("WTLAppWiz.vsz|") != -1)
strLine = "..\\" + strLine;
fileDest.WriteLine(strLine);
}
fileSrc.Close();
fileDest.Close();
}
catch(e)
{
var strError = "no info";
if(e.description.length != 0)
strError = e.description;
WScript.Echo("ERROR: Cannot read and write WTL\\WTLAppWiz.vsdir (" + strError + ")");
return;
}
WScript.Echo("App Wizard successfully installed!");
}
I only changed 2 places. At first it looks it is working and go through all the dialog Boxes where you can change options for your project, but at the end nothing is generated. No project no file. I am not sure what I am doing wrong. Thank you for your reply.
Best regards
Agha Khan
|
|
|
|
|
I
I just realized I also have to change from strLine += ".8.0" to strLine += ".9.0";
It works.
Thanks for reply.
Best regards
Agha Khan (UMIST)
while(!fileSrc.AtEndOfStream)
{
var strLine = fileSrc.ReadLine();
if(strLine.indexOf("Wizard=VsWizard.VsWizardEngine") != -1)
strLine += ".8.0";
else if(strLine.indexOf("WIZARD_VERSION") != -1)
strLine = "Param=\"WIZARD_VERSION = 8.0\"";
else if(strLine.indexOf("ABSOLUTE_PATH") != -1)
strLine = "Param=\"ABSOLUTE_PATH = " + strSourceFolder + "\"";
fileDest.WriteLine(strLine);
}
To
while(!fileSrc.AtEndOfStream)
{
var strLine = fileSrc.ReadLine();
if(strLine.indexOf("Wizard=VsWizard.VsWizardEngine") != -1)
strLine += ".9.0";
else if(strLine.indexOf("WIZARD_VERSION") != -1)
strLine = "Param=\"WIZARD_VERSION = 8.0\"";
else if(strLine.indexOf("ABSOLUTE_PATH") != -1)
strLine = "Param=\"ABSOLUTE_PATH = " + strSourceFolder + "\"";
fileDest.WriteLine(strLine);
|
|
|
|
|
I have defined a struct type in IDL as follows
typedef struct tData
{
int i;
int j;
tData()
{
i = 0; j = 0;
}
}MyData;
Getting error as follows.
error MIDL2025 : syntax error : expecting a type specification near "tData".
|
|
|
|
|
As far as I'm aware, you can't have method declarations in structs in IDL, never mind constructors.
|
|
|
|
|
Seeing a how IDL is interface based, a struct definition could probably contain an interface pointer. If the interface had the method tData() that's probably the nearest you will get to a function pointer.
|
|
|
|
|
Is it possible to declare a CAccessor to allow "smart binding" based on the number of columns
im trying to do something like this
class CProductoAccessor
{
public:
LONG m_ProductoID;
TCHAR m_Nome[51];
TCHAR m_Descricao[51];
DB_NUMERIC m_Preco;
float m_Iva;
TCHAR m_TipoQuantidade[51];
BEGIN_ACCESSOR_MAP(CProductoAccessor, 2)
BEGIN_ACCESSOR(0, true)
COLUMN_ENTRY_LENGTH_STATUS(1, m_ProductoID, m_dwProductoIDLength, m_dwProductoIDStatus)
COLUMN_ENTRY_LENGTH_STATUS(2, m_Nome, m_dwNomeLength, m_dwNomeStatus)
COLUMN_ENTRY_LENGTH_STATUS(3, m_Descricao, m_dwDescricaoLength, m_dwDescricaoStatus)
COLUMN_ENTRY_PS_LENGTH_STATUS(4, 19, 4, m_Preco, m_dwPrecoLength, m_dwPrecoStatus)
COLUMN_ENTRY_LENGTH_STATUS(5, m_Iva, m_dwIvaLength, m_dwIvaStatus)
COLUMN_ENTRY_LENGTH_STATUS(6, m_TipoQuantidade, m_dwTipoQuantidadeLength, m_dwTipoQuantidadeStatus)
END_ACCESSOR()
BEGIN_ACCESSOR(1, true)
COLUMN_ENTRY_LENGTH_STATUS(1, m_ProductoID, m_dwProductoIDLength, m_dwProductoIDStatus)
COLUMN_ENTRY_LENGTH_STATUS(2, m_Nome, m_dwNomeLength, m_dwNomeStatus)
END_ACCESSOR()
END_ACCESSOR_MAP()
what im trying to accomplish is something like this
CCommand < CAccessor <CProductoAccessor> > cmd;
m.Open(m_session, "Select ProductoID, Nome From table");
m.Open(m_session, "Select * From table");
|
|
|
|
|
Hi,
I've installed VS 2008 and i want to create a new ATL Webservice project.
I just downloaded the last update of ATL Server project from Codeplex.com and copied the *.h files into related directories and build the VCDeploy, SProxy and ... utilities.
But i cannot find the ATL Webservice / Server Project template in VS 2008.
Please help me what to do ?!
Regards,
|
|
|
|
|
There's no project wizard/template in the ATL Server project - probably because the one that came in VS2003 (and VS2005? I don't know) is (c) Microsoft.
Two options:- Write it from scratch yourself
- Create an ATL Server project in a version of VS that does have the ATL Server project wizard and then upgrade it into VS2008
|
|
|
|
|
Well, it is sad that there is no way to start new project from VS2008 even when ATL Web Service/Server project has been moved to open communicate (So what the ... developer group do ?!!!!!)
Ok, I've converted one of my old ATL Webservice project to VS9, but i got some errors about :
error C2337: 'request_handler' : attribute not found
error C2337: 'soap_handler' : attribute not found
fatal error C1903: unable to recover from previous error(s); stopping compilation
I googled the web and found out i should use /FX for compiling the project, but i had no luck and got same errors !
Is there anyway to solve this problem ?
(It seems it's time to dotnet ...)
|
|
|
|
|
Seems to me that the ATL server attributes have been removed from the compiler (because that's where they're implemented). Looking at the attribute references for VS2005 and VS2008 on MSDN, you can see that the ATL Server attributes have disappeared between the two releases.
What's wrong with just staying with VS2005 for building ATL Server projects? It's not like you have to be using the latest version - just look at all the people who still use (and prefer) VS6 to build MFC apps...can't for the life of me understand why they prefer VS6, but there you go.
|
|
|
|
|
Hello,
How to use the STL set in C++ in Visual Studio 2005?
thanks and regards,
Software Developer
Sanjay Khapre
|
|
|
|
|
#include <set>
#include <iostream>
int main(int, char**)
{
std::set<int> a_set;
a_set.insert(10);
a_set.insert(1);
a_set.insert(4);
a_set.insert(7);
if (a_set.find(8) != a_set.end())
std::cout << "8 is in the set" << std::endl;
else
std::cout << "8 is NOT in the set" << std::endl;
if (a_set.find(7) != a_set.end())
std::cout << "7 is in the set" << std::endl;
else
std::cout << "7 is NOT in the set" << std::endl;
a_set.erase(7);
if (a_set.find(7) != a_set.end())
std::cout << "7 is in the set" << std::endl;
else
std::cout << "7 is NOT in the set" << std::endl;
}
HTH!!!
|
|
|
|
|
Hi Experts,
I am new to COM programming. (Component Object Model.)
After learning some theory behind COM, I am wondering
Why COM when every thing is possible using DLLs which exports C++ classes.
Or
What is possible only in COM and not possible in C++ DLLs.
Could anyone explain?
Thanks in advance
cheers
Varghese Paul
|
|
|
|
|
COM is intended to be (relatively) language independent (both in terms of class implementers and users). It's designed so that component facilities are discoverable without having to know where or how they're implemented (that's where COM registration comes in).
C++ classes exported from DLLs, on the other hand, don't have those properties. The C++ class methods are exported with mangled names that vary depending on the compiler you're using, so can't be predicted without knowing how the DLL was implemented. Also - they're only DLLs. COM classes can be implemented as in-process servers (COM DLLs), out-of-process servers (COM EXEs) or even on a different machine.
Another thing - memory management. COM objects are reference-counted and use a language independent memory allocator. C++ classes? Manual memory management through the C++ allocator.
|
|
|
|
|
Varghese Paul M wrote: Why COM when every thing is possible using DLLs which exports C++ classes.
That statement is incorrect, as Stuart said. You might want to keep reading, have you seen this?[^]
led mike
|
|
|
|
|
When you write an office addin for say MS Word using ATL after you've performed all the basic steps such as implementing IDExtensibility2 and including the proper typelibs all that's left in order to handle events is to implement IDispEventSimpleImpl using the dispinterface ApplicationEvents2. Then of course you fill in the sink maps with the appropriate values for the events you wish to capture.
This is of course a gross over simplification, but my point is when you have a dispinterface such as ApplicationEvents2 at your disposal your events have ID's associated with them (e.g. 0x00000006 = DocumentBeforeClose)
There is no such convenience when working with PowerPoint. EApplication contains the events you want to handle. However EApplication inherits directly from IDISPATCH. The events do not have id's associated with them (at least not obviously).
Does anyone know how to implement a powerpoint addin using ATL that handles events?
NOTE: Before you include links from Microsofts knowledgebase make sure that the sample actually is about a powerpoint addin using ATL. I've been through many of the links, they come close but do not answer my question. I'm not using c# and I'm not writing any dialog based projects.
|
|
|
|
|
Hi,
I have a structure, i am keeping the structure in vector to store multiple elements,
my structure looks like
struct mystruct
{
id = 1;
pid= 2;
}
i used vector to store like vector<mystruct> vectStruct;
like this i have 100 elements, i need to find the elements whose pid = 2
How can i search structures in vector, how to iterate through result.
Thanks in advance
----------------------------
KRISHNA KUMAR T M
|
|
|
|
|
Use a functor for that:
struct find_pid
{
find_pid ( int pid ) : m_pid_to_find(pid) { }
bool operator() ( const mystruct& s ) const { return m_pid_to_find == s.pid; }
protected:
int m_pid_to_find;
};
vector<mystruct>::iterator i = std::find_if ( vectStruct.begin(), vectStruct.end(), find_pid(2) );
|
|
|
|
|
Hi,
Thanks for your replay,
i tried what you explained in ur replay but when i pass integer to find_pid(4)
but it is giving error like cannot convert from int to mystruct&
----------------------------
KRISHNA KUMAR T M
|
|
|
|
|