|
I'm trying to check the update list from my webserver and then determine whether to update the program.But when i try to write something into my current installed list,it will cause an error for the next move. here is my code:
void CProjectXDlg::CheckUpdate(void)
{
CInternetSession session("Update");
CStdioFile* pFile=NULL;
CStdioFile fUpdateList;
CString strBuf,strBuf2;
pFile=session.OpenURL(host+"updatelist.txt");
fUpdateList.Open("applied.txt",CFile::modeReadWrite|CFile::modeNoTruncate|CFile::modeCreate);
while(pFile->ReadString(strBuf))
{
fUpdateList.ReadString(strBuf2);
if(strBuf!=strBuf2)//not same,go update!
{
fUpdateList.WriteString(strBuf+"\n");
}
}
fUpdateList.Close();
pFile->Close();
if(pFile)delete pFile;
session.Close();
}
the applied.txt will have some weird characters stored in...
|
|
|
|
|
Chooikw wrote:
the applied.txt will have some weird characters stored in...
You are reading from and writing to the same file. What did you expect to happen?
What are the "weird characters" you mention?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
>You are reading from and writing to the same file. What did you expect to happen?
What should I do if I want to compare each line of the file and then correct the applied.txt when it isn't same with the updatelist.txt in my server?
>What are the "weird characters" you mention?
there is lot of "ÍÍÍÍ"
|
|
|
|
|
>What should I do if I want to compare each line of the file and then correct the applied.txt when it isn't same with the updatelist.txt in my server?
Think you can write this data to another file and rename it at the end.
|
|
|
|
|
If the new string is exactly the same length as the old string, you can call Seek() in between the two ReadString() calls. Otherwise, I'd go with *Dreamz's suggestion.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
thx for reply,i'm going with *Dreamz's suggestion.
|
|
|
|
|
I've run into a problem when trying to distribute my application. I'm using a freeware installer called Innno Setup, which is very nice. I have made sure that all of my dlls, config files and even the MSVC redistributable dlls are in the executable directory after install. But still the program dies with a MS VC++ errror. Abnormal program termination. It will not even start. I've gotten it to work on 1 machine which had MSVC7 installed. But machines with MSVC6 installed will not run the program unless it is run from the development environment. The target machines without any development environment throw the same error. So you see, I'm in a bind. Has anyone seen similar behavior?
nay
|
|
|
|
|
This sounds like either the application was built in debug mode and thus requires the debug MFC files, or the application is using an ActiceX control that is not present.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I made sure the app was release mode. Also there are no activex controls in this app. I've followed the directions given in the "Redistributing Microsoft Visual C++ 6.0 Applications" article on MSDN, but still no luck. The thing that's really bothering me is that it's not telling me there's a DLL missing. It's just crashing.
nay
|
|
|
|
|
So have you used the Depends utility to make sure all implicitly-loaded DLLs are present on the target machine?
Can you create a smaller version of your application that reproduces the problem?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
|
HI, I'm using GDI+ to draw curves and i want to erase them too, typically in GDI i would have used SetROP2 using R2_XORPEN but i dont find any such thing in GDI+ can anyone help me out erase a particular drawing say a circle or rectangle etc.. instead of erasing and redrawing the whole screen any help would be greatly appreciated.
|
|
|
|
|
Yes , Thre is not any raster operation in GDI+!
If you are drawing the curve pixel by pixel, add the pixels behind the curve to a list, and redraw them after.
else redraw only the rect that covers by the curve.
but somewhere I have read that It may be better to switch back to GDI somtimes;)
Kamyar Souri
Booria CAD/CAM Systems
www.booria.com
|
|
|
|
|
I have a toolbar button that I want to change dynamically to different solid blocks of colour. I can get a handle to the current image using
tbbi.dwMask = TBIF_IMAGE;
SendMessage(hTB,TB_GETBUTTONINFO,(WPARAM)TB_COLOUR,(LPARAM)&tbbi);
himl = (HIMAGELIST)SendMessage(hTB,TB_GETIMAGELIST,0,0L);
ImageList_GetImageInfo(himl,tbbi.iImage,&ii);
and I can replace the image and tell the toolbar to use the new one using
ImageList_Replace(himl,tbbi.iImage,hbm,NULL);
SendMessage(hTB,TB_CHANGEBITMAP,TB_COLOUR,MAKELPARAM(tbbi.iImage,0));
but in between how do I change the bitmap or create a new one? I've tried
hbm = (HBITMAP)CopyImage(ii.hbmImage,IMAGE_BITMAP,size.cx,size.cy,LR_COPYRETURNO);
selecting into a HDC, and using FillRectEx but it doesn't work. I'm using C and win32 (I don't know C++ or MFC).
Any help appreciated.
thanks
Dave Risley
|
|
|
|
|
Hi all, i would like to know how to create a function that takes a variable number of arguments (parameters), you know, like the CString::Format(LPCTSTR lpszFormat, ... ).
Please note that i do NOT use MFC (i use W32-API and WTL), so even if theres some class, typedef, or whatever that helps with this, but is part of MFC, it wont do me any good.
Any idea of where i should start looking?
Thanks!
|
|
|
|
|
You may just code a simple console (text-mode) application, and trace into printf( ... ).
Maxwell Chen
|
|
|
|
|
#include <stdarg.h>
#include <iostream.h>
double average(int num, ...)
{
va_list arguments;
va_start(arguments, num);
int sum=0;
for(int x=0; x<num; x++)
sum+=va_arg(arguments, double);
va_end(arguments);
return sum/(double)num;
}
int main()
{
cout<<average(3, 12.2, 22.3, 4.5)<<endl;
cout<<average(5, 3.3, 2.2, 1.1, 5.5, 3.3)<<endl;
return 0;
}
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
That looks simple enough, Thanks!
|
|
|
|
|
I have a ListBox ,the complete contents of which I wish to delete.The code
for (int i=0;i < m_userlist.GetCount();i++)
m_userlist.DeleteString( i );
where m_userlist is the variable associated with the ListBox is not working as intended.
Please tell me how to EMPTY the ListBox
|
|
|
|
|
Hi there,
ResetContents();
should do the trick.
The reason why your code is not working:
for (int i=0;i < m_userlist.GetCount();i++)
m_userlist.DeleteString( i );
is because you are deleting the entries incorrectly. The first pass of your loop will delete entry 0, thus entry 1 will now be entry 0. But in the next pass, you will be deleting entry 1 (missing out the newly appointed entry 0)
To achieve the above correctly use:
int nCount = m_userlist.GetCount();
for (int i=0;i < nCount;i++)
m_userlist.DeleteString(0);
Cheers,
Andy
|
|
|
|
|
ResetContents() didn't work .The error was that
'ResetContents' : is not a member of 'CListBox'
But your correction of the code that I had erred in worked .Thanks
|
|
|
|
|
ResetContents() didn't work .The error was that
'ResetContents' : is not a member of 'CListBox'
But your correction of the code that I had erred in worked .Thanks
|
|
|
|
|
shals169 wrote:
ResetContents() didn't work .The error was that
'ResetContents' : is not a member of 'CListBox'
But your correction of the code that I had erred in worked .Thanks
Sorry there,
That should have been ResetContent()
My mistake
Here's the link to the class members for CListBox at MSDN
Cheers,
Andy
|
|
|
|
|
When should you use :: when calling certain methods;
e.g. for closing handles in a MFC application (OK Button)
::UnmapViewOfFile(m_pMsg);
::CloseHandle(m_hMap);
CloseHandle (m_hIDUMutex);
This also applies to other methods; e.g. timers
CBDialog::OnTimer(nIDEvent);
where CBDialog is my dialog class.
Are they any rules? For example should I use the following for closing the Mutex handle?
::CloseHandle (m_hIDUMutex); // Control Mutex
|
|
|
|
|
Hi,
:: is the scope resolution operator, so ultimately there is no difference between
::UnmapViewOfFile(m_pMsg) and
UnmapViewOfFile(m_pMsg)
unless you had a function called UnmapViewOfFile() in the same scope as you are calling it.
Here's the link to MSDN for you.
Hope this helps,
Andy
|
|
|
|