|
followait wrote: But I can't agree that header files contains so much implementations code,
Template code *has* to be in headers if you're going to instantiate it for different template parameters, because every time you instantiate, you create a new implementation of the class/function.
|
|
|
|
|
|
If it is, where can I find it?
Thanks.
|
|
|
|
|
Not open as such, but it gets installed with versions of Visual Studio you pay for. In my VS2008 installation, it's in C:\Program Files\Microsoft Visual Studio 9.0\VC\crt\src.
|
|
|
|
|
Actually is should be here (along with other things): "C:\Program Files\Microsoft Visual Studio 9.0\VC\include". The CRT and the STL are two different things.
Steve
|
|
|
|
|
Call it a tie - we're both correct. Yes, CRT and STL are different, and yes, the include directory has most of the STL, but there's a reasonable amount of it that's in the crt/src directory as well (mostly code that's common across all template instantiations and pre-instantiated items like std::string (==std::basic_string<char> ) and the streams.
|
|
|
|
|
I had problem in migrating from VC6 to VC2005
typedef _A::size_type size_type; works fine in the vc 6 and flashes the below error after migrating to VC 2005
"thirdparty\dinkumpatches\xstring(39) : error C2146: syntax error : missing ';' before identifier 'size_type'"
pls advice
|
|
|
|
|
it looks like the "_A" isnt defined. Look where it was defined in the VC6 and than you why it isnt defined in VS2005. I guess it is a define which surrounds the "_A". Bad code
Greetings from Germany
|
|
|
|
|
Hi all,
In mfc I use CInternetSession to download files from an http server. What can I use via WTL?
Thanks,
Jayjay
|
|
|
|
|
|
Thanks,
Sorry what i meant was what can i use for ATL not WTL an ATL version of CInternet session.
|
|
|
|
|
You should be able to use this with ATL, it just wraps the WinInet API.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Hi,
Will the distribute mfc libraries? Or even static link?
Because I think this still will.
Thanks,
Jayjay
|
|
|
|
|
Look at the code he pointed at - the only thing it references is WinInet - which is distributed as part of Windows, NOT MFC.
If you're conversant with the MFC classes, as you are, you're not going to find anything much easier or better than that wrapper - the only change I'd make would be to wrap the classes in a namespace so the names don't collide with MFC.
|
|
|
|
|
Thanks I am now using it, now I can't understand how I can write a file that i have downloaded.
Here is my code:
<br />
CString strStaus;<br />
CInternetSession Session(_T("Test Application"));<br />
CHttpConnection Connection1(Session,_T("http://10.5.1.4/downloads/Managepoint/ManagePoint431InstallerBuild_55.zip") ) ;<br />
BYTE Buffer[4096];<br />
<br />
<br />
CHttpFile File2(Session,_T("http://10.5.1.4/downloads/Managepoint/ManagePoint431InstallerBuild_55.zip") ) ;<br />
for (DWORD dwRead2;dwRead2=File2.Read(Buffer,sizeof(Buffer)) ; ) <br />
{<br />
}<br />
Thanks,
Jj
|
|
|
|
|
CHttpFile File1(Connection1,_T("GET"),_T("/"));
File1.SendRequest();
ULONGLONG const nBytes = </code><code>File1.GetLength();</code>
<code>BYTE* bytes = new BYTE[</code><code>nBytes</code><code>];
File1.Read(bytes ,</code><code>nBytes</code><code>) ;
HANDLE hFile = CreateFile(some-file-name, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
DWORD bytesWritten;
WriteFile(hFile, bytes, (DWORD)nBytes, &bytesWritten, 0);
CloseHandle(hFile);
I've assumed the file you're downloading is < 2GB (should be a safe assumption) and haven't put in any error handling. But that should work.
|
|
|
|
|
Thanks what i did to write was
<br />
for (DWORD dwRead2;dwRead2=File2.Read(Buffer,sizeof(Buffer));)
{<br />
fwrite(Buffer, sizeof (char), dwRead2 , pFile); <br />
}<br />
|
|
|
|
|
I got the header sorted out now, i got an important question though. How can I prevent the re-download of the file if it is already successfilly downloaded because the problem is that after i successfully downloaded the file and restarted my program it downloads again and adds the files to the complete files thus doubling the size of the file and making the file useless.
<br />
std::string strTmpFileName = "Temp_OutlookAddinInstallerBuild_30.zip";<br />
std::string strFileNameAtLocalMachine= "OutlookAddinInstallerBuild_30.zip";<br />
<br />
CString strStaus;<br />
double dCurrentFileSize;<br />
<br />
DWORD dwBytesWrrittenToFile =0;<br />
<br />
if(IfLocalFileExist(strTmpFileName.c_str(), &dCurrentFileSize)) <br />
{<br />
dOffsetToSeek = dCurrentFileSize;<br />
}<br />
<br />
CString strRangeQuest;<br />
<br />
if(dCurrentFileSize>0){ <br />
strRangeQuest.Format( _T("%sRange: bytes=%d-\r\n"), szHeaders,static_cast<ULONGLONG>(dCurrentFileSize));<br />
}<br />
else <br />
strRangeQuest = szHeaders;<br />
<br />
dwBytesWrrittenToFile = dOffsetToSeek;<br />
<br />
if ( !(pFile = fopen (strTmpFileName.c_str(), "ab" ) ) )<br />
{<br />
CString strMsg;<br />
strMsg.Format("Error:%d", GetLastError());<br />
return false;<br />
}<br />
if(dOffsetToSeek >=0)<br />
{<br />
strStaus.Format("Seeking to local file...");<br />
int n = fseek(pFile, dOffsetToSeek, SEEK_SET);<br />
}<br />
<br />
CInternetSession Session(_T("Test Application"));<br />
CHttpConnection Connection1(Session,_T("http://10.5.1.4/downloads/OutlookAddin/OutlookAddinInstallerBuild_30.zip"));<br />
BYTE Buffer[4096];<br />
<br />
CHttpFile File2(Session,_T("http://10.5.1.4/downloads/OutlookAddin/OutlookAddinInstallerBuild_30.zip"));<br />
CInternetFile::CInfo Info(File2);<br />
File2.SendRequest(strRangeQuest);<br />
int FileSize = Info.GetTotalDataLength();<br />
<br />
if (FileSize == dCurrentFileSize)<br />
{<br />
return 0;<br />
}<br />
<br />
for (DWORD dwRead2;dwRead2=File2.Read(Buffer,sizeof(Buffer));)<br />
{<br />
fwrite(Buffer, sizeof (char), dwRead2 , pFile); <br />
}<br />
<br />
MoveFile(strTmpFileName.c_str(), strFileNameAtLocalMachine.c_str() );<br />
<br />
return 0;<br />
Thanks,
jayjay
|
|
|
|
|
monsieur_jj wrote: How can I prevent the re-download of the file if it is already successfilly downloaded because the problem is that after i successfully downloaded the file and restarted my program it downloads again and adds the files to the complete files thus doubling the size of the file and making the file useless.
Check for file existence when starting the download process - if the file you want to write is already present, you need to take some action, whether it's overwriting the file or writing to a differently named file.
|
|
|
|
|
I got the writing sorted out however im still looking for ways to have a pause resume capability,
<br />
BYTE Buffer[4096];<br />
<br />
CHttpFile File1(Connection1,_T("GET"),_T("/"));<br />
File1.SendRequest();<br />
for (DWORD dwRead1;dwRead1=File1.Read(Buffer,sizeof(Buffer)););<br />
<br />
CHttpFile File2(Session,_T("http://www.codeproject.com/"));<br />
for (DWORD dwRead2;dwRead2=File2.Read(Buffer,sizeof(Buffer)););<br />
I am getting an error C2668 'function' : ambiguous call to overloaded function at File1.
what can i do to resolve this?
|
|
|
|
|
hey every one...i have a prob.....i am making a program which will generate an exe...i want when i run my program....it should make a text file which is not a problem and one exe file...which is some other program that i built......not the same as the program from which im making this exe....what should i do for that??? i just had a random idea in my mind...i though every file is a file...why not try like text file..so i changed the extension of the exe(that i want to generate by running other one i.e. exe that i want to produce) in txt...then copied that into fputs("all the converted file contents here", outfile)....then tried to run...changed all escape seqence and all( like " changed to \" )...but didn't work as i expected....i knw its a very lame idea.... ...can someone tell me how to do this....any idea guys??/
there are 10 type of people in the world...
01 who understand binary.
10 who don't...
|
|
|
|
|
This is not really an ATL, WTL or STL question. But, as I'm a nice guy, I'll suggest you open your files in binary mode (fopen(filename, "rb") or fopen(filename, "wb") , so that the C run-time doesn't do any translation of line-ending characters.
Alternatively (and this is better), you can embed the executable file you want to write as a resource in the program that is generating it. Here's a function that should load and write a named resource:
#include <Windows.h>
#include <ShlWApi.h>
bool WriteFileFromResource(HINSTANCE hmodResource, LPCTSTR name, LPCTSTR type, LPCTSTR destination)
{
if (!type)
type = ::PathFindExtension(name) + 1;
HRSRC rsrcFile = ::FindResource(hmodResource, name, type);
if (!rsrcFile) false;
HGLOBAL gblFile = ::LoadResource(hmodResource, rsrcFile);
if (!gblFile) false;
DWORD sizeFile = ::SizeofResource(hmodResource, rsrcFile);
if (!sizeFile) return false;
LPVOID filePointer = ::LockResource(gblFile);
if (filePointer)
{
bool ret = false;
HANDLE hFile = ::CreateFile(destination, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
if (hFile)
{
DWORD nBytesWritten;
ret = (::WriteFile(hFile, filePointer, (DWORD)sizeFile, &nBytesWritten, 0) && sizeFile == nBytesWritten);
::CloseHandle(hFile);
}
::FreeResource(gblFile);
return ret;
}
return false;
}
|
|
|
|
|
I need to develop a COM dll which will read data from a serial port.
I am very new to COM programming.
Please help me regarding this.
|
|
|
|
|
What is the problem ? Where are you stuck ? What did you try so far ?
|
|
|
|
|
I just learnt to create a simple object in ATL.
Now my requirement is to write an object which will open a serial port and read data from it.
I got some code which will make use of CreateFile and read data from it.
But i dont know exactl where can use the code what will be the function return type because i am developing a ATL dll.
So i am unable to procede further.
|
|
|
|
|