|
So is your question about GetVersionInfo() returning the correct value, or how to copy over a potentially in-use file?
|
|
|
|
|
My question is how to use GetVersionInfo() to return the correct value.
Thanks
|
|
|
|
|
This article should help:
http://www.microsoft.com/msj/0498/c0498.aspx
|
|
|
|
|
I use the following in a application.. It seems to work fine for pulling the version info..
CString CMainFrame::GetVerInfo(CString strFile)
{
DWORD size = GetFileVersionInfoSize(strFile.LockBuffer(),0);
strFile.UnlockBuffer();
if(size > 0)
{
CString results;
char *pData = new char[size];
if(GetFileVersionInfo(strFile.LockBuffer(), 0, size, pData))
{
strFile.UnlockBuffer();
VS_FIXEDFILEINFO* lpvi;
UINT iLen;
if(VerQueryValue(pData,"\\", (void **)&lpvi, &iLen))
{
results.Format("%u.%u.%u.%u",HIWORD(lpvi->dwFileVersionMS),
LOWORD(lpvi->dwFileVersionMS),
HIWORD(lpvi->dwFileVersionLS),
LOWORD(lpvi->dwFileVersionLS));
}
}
delete[] pData;
return results;
}
else
return "Unknown";
}
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
BOOL CVersionDlg::OnInitDialog()
{
......... regular MFC exe wizard .......
SetTimer(1, 5000, NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
void CVersionDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CString strFile = "E:\\MyProjects\\version\\Debug\\version.exe";
DWORD size = GetFileVersionInfoSize(strFile.LockBuffer(),0);
strFile.UnlockBuffer();
if(size > 0)
{
CString results;
char *pData = new char[size];
// GET THE FILE VERSION AND STORE IT IN pData
if(GetFileVersionInfo(strFile.LockBuffer(), 0, size, pData))
{
strFile.UnlockBuffer();
VS_FIXEDFILEINFO* lpvi;
UINT iLen;
if(VerQueryValue(pData,"\\", (void **)&lpvi, &iLen))
{
// FORMAT THE VERSION EXAMPLE ( 1.2.3.1 )..
results.Format("%u.%u.%u.%u",HIWORD(lpvi->dwFileVersionMS),LOWORD(lpvi->dwFileVersionMS),
HIWORD(lpvi->dwFileVersionLS),LOWORD(lpvi->dwFileVersionLS));
MessageBox("Version", results);
}
}
delete[] pData;
}
CDialog::OnTimer(nIDEvent);
}
Make 2 version.exe, put one with version 1.0.0.1 (version1.exe) and the other one 1.0.0.5 (version5.exe).
Copy version1.exe to version.exe.
Run version.exe. A dialog should pop up 1.0.0.1 every 5 seconds.
Rename version.exe to version.bak. The dialog should cease popping up.
Copy version5.exe to version.exe. The dialog will pop up again still with 10.0.0.1 (while it should be 10.0.0.5).
So still no solution
|
|
|
|
|
I'm assuming that version.exe is not the name of the program that this code is in right?
If it is, I didn't think you could rename the exe while it was running..
If not, not sure why it's not working, strange.. Is your file name/path defined in the timer like the code above or are you actually putting the file name/path in a member variable?
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
It is. Yes you can rename it. It seems like Windows OS doesnt care much about filename as long as it already acquired the handle for exe. Done this a few times.
And you are right if it is not the file that is running, it works fine. I just hard code the exe filename because my project is called version.dsp. Just for a test program.
I guess this rename - copy - check version idea doesnt work.
Thanks!
|
|
|
|
|
is there a special forum for directx (visual c++)?
hope get links.
thx
includeh10
|
|
|
|
|
Nope, post your questions here if you are using c++.
John
|
|
|
|
|
|
I would like to disconnect the already existing dialup connection from my program. But the dialup connection was not made from my program. Can anyone tell me how this can be possible? InternetHangup() can only be used with the handle returned from InternetDial() function. But because the dialup connection is already existing, can I still call InternetDial() to get the handle and then use it with InternetHangup()? It doesn't seem to work this way. Is there any other way to do this. Please let me know if you know.
Thanks
JDasari
|
|
|
|
|
Use RasEnumConnections() and RasGetConnectStatus() to find all active connections and then call RasHangUp().
|
|
|
|
|
#include <ras.h>
#define MAX_CONNECTIONS 128
void HangUpConnections()
{
RASCONN rcConnection[ MAX_CONNECTIONS ];
DWORD dwBufferSize;
DWORD dwTotalConnections;
int nLoop;
rcConnection[0].dwSize = sizeof( RASCONN );
dwBufferSize = MAX_CONNECTIONS * sizeof( RASCONN );
if( RasEnumConnections( rcConnection, &swBufferSize, &dwTotalConnections ) )
return;
if( dwTotalConnections )
{
for( nLoop = 0; nLoop < (int) dwTotalConnections; nLoop ++)
{
RASCONNSTATUS rcsStatus;
rcsStatus.dwSize = sizeof( RASCONNSTATUS );
if( RasGetConnectStatus( rcConnection[ nLoop ].hrasconn, &rcsStatus ) )
break;
if( rcsStatus.rasconnstate == RASCS_Connected )
{
if( RasHangUp( rcConnection[ nLoop ].hrasconn ) )
break;
}
}
}
}
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Thank you all from our Team for your responses. Your input was really helpful and it works.
|
|
|
|
|
How to nuke left and right "Windows" key in my MFC/DirectX fullscreen application? VK_APPS seems to be filtered by CMyWnd::PreTranslateMessage , VK_?WIN do not.
Regards,
BB
|
|
|
|
|
|
I Load and draw Picture
in OnEraseBkgnd(CDC* pDC),
I than need label to not overdraw background,
and do
<br />
<br />
<br />
HBRUSH cWaitDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)<br />
{<br />
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);<br />
<br />
<br />
pDC->SetBkMode(TRANSPARENT);<br />
<br />
<br />
return hbr;<br />
}<br />
Why backgound is overdrawn?
thanks you.
|
|
|
|
|
Try
return (HBRUSH)GetStockObject(NULL_BRUSH);
instead of
return hbr;
Steve S
|
|
|
|
|
if you donot like 'stock object' try this . It should work.
LOGBRUSH lb;
lb.lbStyle = BS_HOLLOW;
return CreateBrushIndirect(&lb);
|
|
|
|
|
if you dont like using 'stock objects', try using this
It should work
LOGBRUSH lb;
lb.lbStyle = BS_HOLLOW;
CreateBrushIndirect(&lb);
|
|
|
|
|
Problem with non-stock object approach is that you may inadvertently leak GDI objects, unless you track them in the parent CDialog.
Another approach would be to derive from CStatic, use message reflection so that the object handles it's own WM_CTLCOLORSTATIC, and returns a singleton hollow brush.
The stock object null/hollow brush could be used there too, and you'd use control variables to associated dialog members to the appropriate control(s).
Steve S
|
|
|
|
|
Beter if you explain ...
Code that work:
hbr = NULL;
{
if( CTLCOLOR_STATIC == nCtlColor )
{
hbr = (HBRUSH)GetStockObject( HOLLOW_BRUSH );
pDC->SetBkMode( TRANSPARENT );
}
else
{
hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
}
return hbr;
}
thanks you for response.
|
|
|
|
|
Hi All,
I would like to know whether there is any API provided by the
Windows OS for packet filtering dynamically. Usually we can configure this
from the Control Panel Settings, but it needs restart. Is there any method
to do it without any restart needed.
Thanks.
Learning is a never ending process of Life.
|
|
|
|
|
what is the architecture of MAPI?
I use SIMPLE MAPI in my c++ client program..
is there any necessity to install! MAPI for this purpose in my computer??how do i do it iff i have to install MAPI??
ranjani
|
|
|
|
|
Hi All,
I have a silly question about radio buttons that seems pretty simple but yet i can't get to work.
I have a dialog with 2 radio buttons to allow the user to select one of two choices. I initially set one as default using CheckRadioButton(IDC_B1, IDC_B2, IDC_B1) . I want my program to remember which one is selected by the user, so that if they open the dialog again through a pull down menu it will select the same one as the user selected before.
can someone tell me how to do this exactly, i don't know what i am doing wrong.
Thanks for your help.
|
|
|
|