|
Hi,
I created a simple MFC dialog application and added a custom interface to the application via the wizard. I also included the typelib in the .rc file. This all seems to be rather easy, but when I try to query the interface of the COM object in a client application, the hresult is 0x80004002.
I registered the application and when I lookup the the coclass and typelib in the OLE/COM object Viewer, I can find both of them but the interface I cannot find. So it seems the interface is not registered (I also cannot find the IID in the registry).
Is the interface not always automatically registered when the typelib is registered? The application does not seem to have a proxy/stub makefile, so I also can not nmake that and register it.
Any one know what the cause of this problem is?
|
|
|
|
|
I am trying to implement a Paste function that will read data from excel and paste it to another spread sheet type container. I don't need detailed data for this program; the CF_TEXT format would suit my needs fine. However, when using IsDataAvailable(CF_TEXT), this returns TRUE whether there is data there or not. I would like to be able to verify that excel has put data on the clipboard before trying to process the data.
I have registered and tried to get "XlTable" format data from the clipboard, but IsDataAvailable returns false when passing this format as a parameter -- even when I have just used excel to copy to the clipboard. Can anyone give me some idea as to a format that excel uses to put data to the clipboard? This would be greatly appreciated.
|
|
|
|
|
1. Visual Studio 6.x Tools => DataObject Viewer => Clipboard => Empty Clipboard
2. Copy something in Excel
3. Visual Studio 6.x Tools => DataObject Viewer => Clipboard => View Clipboard Data Object
Results From Excel 2000
Unknown Clipformat ptd={NULL} dwApsect={Content } lindex={-1} tymed={}
CF METAFILEPICT ptd={NULL} dwApsect={Content } lindex={-1} tymed={MFPict }
CF-BITMAP ptd={NULL} dwApsect={Content } lindex={-1} tymed={GDI }
Biff8 ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
Biff5 ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
BIFF4 ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
Biff3 ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
Biff ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
CF SYLK ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
Wkl ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
CF DIF ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
HTML Format ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
Unknown Clipformat ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
CF TEXT ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
Csv ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
Hyperlink ptd={NULL} dwApsect={Content } lindex={-1} tymed={IStream }
CF TEXT ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
Rich Text Format ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
Embed Source ptd={NULL} dwApsect={Content } lindex={-1} tymed={IStorage }
Object Descriptor ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
Link Source ptd={NULL} dwApsect={Content } lindex={-1} tymed={IStream }
Link Source Descripto ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
Link ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
CF DSPTEXT ptd={NULL} dwApsect={Content } lindex={-1} tymed={hGlobal }
|
|
|
|
|
OK so here's my current situation.
I have a program that I put in the shared network drive. People are using this program a lot, so upgrading is a bit pain in the neck. First I have to rename the exe, copy the new exe, then find all the active instances of the program and close them, then delete it. Works great until couple weeks ago where I thought I close every active instance and I still couldn't delete it. Had to ask admin guy to delete it.
So I decide to go with slightly more clever way: get a timer to periodically check the exe version.
Suppose I have a.exe, and I rename a.exe to a.exe.bak and put a.exe with newer version in. If somebody still have the instance of a.exe.bak running, it will check a.exe for newer version, and will close that instance.
Great in theory, but it doesnt happen! For some reason the code to check the version using GetVersionInfo("a.exe"...) always return the old version even if the old a.exe has been renamed to a.exe.bak and a.exe that has higher version is put in the same directory. I suspect this is because the code still thinks the handle to open the old a.exe is still open or something. Any help?
Thanks a bunch!
|
|
|
|
|
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
|
|
|
|