|
Hi, all
Does anybody knows a good control or source code to add this (web update) feature to MFC application?
AutoUpdate will be great for now, but if there are one that could ask user which version to download - will be the best one.
Thanks all.
|
|
|
|
|
hain buddy,
i think you have to implement your onlogic and implemetation for above, but i will point you to some of api and logic that will help.
#1 for downloading file form internet use UrlFiletodownlaod api or look the article written by Mr Micheal Dunn.
#2 now for checking how many version of your software listed at your site,make a query page and though that any parser or xml way retrieve all the version of software listed on your website ,and using your logic display that to user and ask for upgrade.
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
yeah, buddy
thanks for coming up... but that all is theory and all that theory i know well, but i now need code or control :
no time to code
thanks for reply.
|
|
|
|
|
Really,i am sorry the code is created is no use for you as it embedded in my project and yeah,it do have auto updation function,but it is dependent of type of setup i am creating.
here is small code snippet that will help
//here this code snippet that check for version
<br />
CAmHttpSocket am;
CRegKey key;<br />
<br />
<br />
LPSTR tmpstr,lpstrurl;<br />
<br />
DWORD dwSize=0;<br />
<br />
struct tm *newtime;<br />
time_t long_time;<br />
time( &long_time ); <br />
newtime = localtime( &long_time );<br />
<br />
DWORD CurrentDate,RegDate;<br />
<br />
CurrentDate=MAKEWPARAM(newtime->tm_yday,newtime->tm_year); <br />
<br />
if(key.Create(HKEY_CURRENT_USER,PRODUCTREGLOCATION)!=ERROR_SUCCESS)<br />
return FALSE;<br />
key.QueryValue(RegDate,"lastupdate");<br />
<br />
<br />
if(CurrentDate==RegDate)<br />
return FALSE;<br />
else<br />
{<br />
key.SetValue(CurrentDate,"lastupdate");<br />
}<br />
<br />
<br />
<br />
key.QueryValue(NULL,"updationurl",&dwSize);<br />
if(dwSize>0)<br />
{<br />
tmpstr=new char[int(dwSize+1)];<br />
key.QueryValue(tmpstr,"updationurl",&dwSize);<br />
<br />
<br />
}<br />
else<br />
return FALSE;<br />
<br />
<br />
<br />
<br />
<br />
lpstrurl=new char[200];<br />
sprintf(lpstrurl,"%s?updateversion=%f",tmpstr,PRODUCTVERSION);<br />
<br />
delete []tmpstr;<br />
<br />
<br />
LPSTR lpXMLPage=NULL;<br />
<br />
lpXMLPage=am.GetPage(lpstrurl);<br />
<br />
<br />
<br />
CString csRetVersion,csFileURL;<br />
if(lpXMLPage)<br />
{<br />
this->Return_Element_Value((LPCTSTR)lpXMLPage,"version",csRetVersion);<br />
this->Return_Element_Value((LPCTSTR)lpXMLPage,"url",csFileURL);<br />
<br />
<br />
<br />
double version=atof(csRetVersion);<br />
if(version>PRODUCTVERSION)<br />
{<br />
this->m_strDownloadURL=csFileURL;<br />
return TRUE; <br />
}<br />
<br />
<br />
<br />
<br />
<br />
}<br />
and here is Downloading thread
<br />
<br />
CString sPath;<br />
<br />
char lpapplicationpath[301];<br />
::GetModuleFileName(NULL,lpapplicationpath,300);<br />
char sDrive[10],sDirectory[200];<br />
<br />
::_tsplitpath(lpapplicationpath,sDrive,sDirectory,NULL,NULL);<br />
CString Path1;<br />
Path1.Format("%s%s",sDrive,sDirectory);<br />
Path1.TrimRight('\\');<br />
<br />
sPath.Format("%s%ssetup.exe",sDrive,sDirectory);<br />
<br />
CString RunableExe;<br />
<br />
RunableExe.Format("%s%ssetup.exe /SP- ",sDrive,sDirectory);<br />
<br />
if(::URLDownloadToFile(NULL,m_Dlg->m_strDownloadURL,sPath,NULL,NULL)==S_OK)<br />
{ <br />
<br />
<br />
m_Dlg->m_strFilePath=sPath;<br />
m_Dlg->PostMessage(MESSAGE_EXECUTE,0,0);<br />
}<br />
<br />
m_Dlg->PostMessage(MESSAGE_EXECUTE,0,0);<br />
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
one more big thanks!
you pointed me in right direction with CAmHttpSocket...
but how to measure current speed? you know like in "true" cool updaters )
thanks.
|
|
|
|
|
HI,
I have developed one console applicatoin using VC++ 6.0. I have used InternetGetConnectedState() api to retrieve internet status.
This api fails when I run my application on WINDOWS ME, but runs well on other operating systems.
what is the reason of failure on WINDOWS ME?
Is there any other way to know about the availability of internet, i.e. whether using proxy server or dial up, ?
bye
bhavesh
|
|
|
|
|
Hey Bhavesh,
Could u please send me the code u r using to know the status of internet connection as i need it in my application.
And i hope some one wil b able to solve ur problem.
Thx,
regards,
Prax
|
|
|
|
|
http://windows.oreilly.com/news/dialup_0600.html
This link wil be helpful to u and also good help is available at msdn .
Plesae sned the code u r using
thx,
Prax
|
|
|
|
|
|
While I think a solution has already been provided, here are a few other ways of checking connectivity that you might need to know about:
http://www.pcausa.com/resources/InetActive.txt
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi
I am sending my custom message from one CWnd derived class to another CWnd Derived class using ::SendMessage function. the problem is that i also have to send two CString objects along with this message ( say via WPARAM or LPARAM) but i donot know how to do it.
or in other words how do we send data ( say structure or any object ) along with SendMessage Fuction.
Thanks in anticipation
Azam
|
|
|
|
|
i think you should take a look at WM_COPYDATA message
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Since you are sending the CStrings within the same process and synchronously with SendMessage I'd simply cast the adresses of the two CString objects to WPARAM and LPARAM. If you need more room the the 64 bits that these two parameters give you you can allocate a struct on the stack and pass the adress of it in e.g. LPARAM
<br />
CString cs1, cs2;<br />
<br />
res = ::SendMessage(hwnd, WM_MYMESSAGE, (WPARAM)&cs1, (LPARAM)&cs2);<br />
or
<br />
class CMyMessageData<br />
{<br />
public:<br />
CString m_str1;<br />
CString m_str2;<br />
....<br />
}<br />
<br />
<br />
CMyMessageData data;<br />
data.m_str1 = cs1;<br />
data.m_str2 = cs2;<br />
<br />
res = ::SendMessage(hwnd, WM_MYMESSAGE, 0L, (LPARAM)&data);<br />
But don't use this technique to send data to a window in another process or thread, or to send data using PostMessage.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
How would you go about sending the strings from another thread?
ed
The absence of evidence is not evidence of absence.
|
|
|
|
|
Hi,
Frankly, I'm not sure that there is any problems with sending the strings between threads in the same process, but I vaguely remember something about CString and threads, you'll have to look it up un MSDN.
Inter-thread communication is always faced with the challenge that the two (or more) threads can access the data simultaneously, so you'll need to protect the integrity of the data by using one of the synchronization tokens. Or, if the data you send are going to be read only in the receiving thread it's best to pass a copy instead of a reference (when you pass the address of the CString objects in WPARAM and LPARAM they are of course passed by reference).
Of course, if the receiving thread is in another process the problems gets worse, as the two threads now don't even share a memory space.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Hi Steen
Thankyou very much for guiding me in such an ellaborative manner, i really don't have words to convey my gratitudes. i have included your method in my code and its working excellent now
could you plz teach me one more thing. What will happen if cs1 or cs2 ( or data object) goes out of scope before the window pointed by hwnd receives (or pumps out) the message from message queue.
also what will happen if i change values in cs1 or cs2 before the window pointed by hwnd receives the message from message queue.
any ways once again thank you very much and plz give some time to these question of mine as well i will be very thankful to you
regards
Azam
|
|
|
|
|
Hi Muhammad,
this is why I made the distinction between SendMessage and PostMessage. SendMessage is synchronous meaning that it will call the receiving windows' WindowProc directly, bypassing the message queue. So the call to SendMessage will behave exactly as any other function call. It is not possible for cs1 or cs2 to go out of scope or to be changed by the caller during the call. What the callee does with the data is another matter, and these changes will be relayed back to the caller as you have passed cs1 and cs2 as references (pointers).
The points you have here are absolutely valid if you use PostMessage. It's a "fire-and-forget" call - you have no control or knowledge about when the callee will execute. In this case it's best to pass a copy of the data in the call:
<br />
LPTSTR lpsz1 = new TCHAR[cs1.GetLength()+1];<br />
_tcscpy(lpsz1, cs1);<br />
::PostMessage(hwnd, WM_MYMESSAGE, (WPARAM)lpsz1, 0),<br />
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Hi Steen
once again thank you very must for explaining me all these, your way of defining things is superb and ful explainatory. Now its crystal clear to me the difference b/w SendMessage and PostMessage, i have always been confused b/w them, any ways you have been a source of knowledge for me.
thanks a lot
regards
Muhammad Azam
|
|
|
|
|
Hi,
I have got Problem With ActiveX.I created ActiveX Using OWC. i tested this activex in dialog based apllication. when i closed(on application termination) the dialog got an error , memmory location feefee() could not read. problem is my program is try to free the memory that isn't allocated.how can override this problem.
by
baijumax
|
|
|
|
|
i have an application using visual c++ 5.0 where a right-click on an application toolbar icon gives a submenu. The submenus initially come up correctly, but then quickly go into the background behind the application toolbar or existing context menus. Seems to be intermittent too, sometimes they'll stay in foreground.
Also getting this problem with the windows that pop up from a click on a 'What's This' help.
The winhelp calls are all:
WinHelp(..,..,HELP_CONTEXTMENU,..)
Any ideas how I keep the new screens in the foreground?
Thanks,
tkd
|
|
|
|
|
Alright...this is a small part of a problem I'm doing for C++ class..We have to store a floating integer T. T=1.5 . Now, we have to convert this stored value to hex...Kinda like this:
float t;
t = 1.5;
std::hex << t << "\n";
Or whatever..You get the idea tho..store the value, and convert it to it's hex format.
Have any suggestions?
|
|
|
|
|
hello,
i think you ar elooking for sprintf() function
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
depends how do you want to convert it to hex ... you know usually only ints are converted to hexes ... floating part is not carried over.
You could do printf( "%X", (int) t ); to print it in hex, but it will print only integer part.
If you want to print its binary representation you could do printf( "%08X", *((long*) &t) );
|
|
|
|
|
I have an unusual piece of code that i am writing where i need to output 3 rectangles of 3 different sizes to a window and alternate them every second. Basically it shows a new rectangle every second. Anyhow i can do it where the rectangles are alternated its just if a smaller rectangle appears on a larger one that on doesn't go away. Is there an MFC function that i am missing?
|
|
|
|
|
YEah look for invalidateRect() api that may help in above cause
basically this api repaint any given rectangular position in the given window.
now follow simple logic,first copy the image data or triangle coordinate in another variabel ,which you want to display and send message to window to repint that position
like this(remember this is logic)
triangle a,b,c & tmp;
you hav displayed them at any given time,
now oN WM_TIMER message of Seconds
copy one triangle in another like this
tmp=a;
a =b;
b=c;
c =tmp;
and call invalidate() to repaint or display the triangle
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|