|
Hi All
my application throw exception.
Unhandled exception at 0x0052aba7 in application.exe;0x0000005;Access violation reading location 0x0000000.
I am useing clipboard.Code is here
OpenClipboard(NULL);
EmptyClipboard();
CloseClipboard();
CString szText1;
LPDATAOBJECT pDO;
TCHAR szPath122[MAX_PATH];
HRESULT hr = OleGetClipboard(&pDO);
FORMATETC fmt = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
STGMEDIUM stgm;
hr = pDO->GetData(&fmt, &stgm);
if(S_OK == hr)
{
UINT nFiles = DragQueryFile((HDROP)stgm.hGlobal, -1, NULL, 0);
i = 0;
for( i = 0; i < nFiles; i++)
{
ij=1;
DragQueryFile((HDROP)stgm.hGlobal, i, szPath122, MAX_PATH);
szText1 += szPath122;
szText1 += "\r\n";
}
ReleaseStgMedium(&stgm);
}
pDO->Release();
Exception throw in this line
<code>hr = pDO->GetData(&fmt, &stgm);</code>
How can i slove this exception.Plz help me
|
|
|
|
|
HRESULT hr = OleGetClipboard(&pD0);
hr = pDO->GetData(&fmt, &stgm);
Before using pD0 , you have to verify if pD0 is valid.
Maxwell Chen
|
|
|
|
|
Hi,
I have converted my MFC Application to a dll, which i can just call from a Windows forms Application i have achieved sucess to open that application as dll and everthing else is working fine, but update_command_UI for the Toolbar used doest not work, initialy loading, the application calls Update_Command_UI. Pls Suggest me some help..
Thanks
Samir
|
|
|
|
|
|
Hi David,
I hv changed the code but still it has not helped me.. I have done following steps
to Make my MFC Application to DLL
a) the WinApp of my application i have made as the Win App Of the DLL
b) Rest All Required .h and .cpp i have added to Dll
c) Changed the Resources Accordingly
d) Created a Function which will be called from Dll (this Function is empty)
d)Created a Windows forms Application =>created a Form =>Added Button
=> On Click of Button i am Calling the dll function using pInvoke(DLLImport)
My Application all is Getting Open.. For MenuBars Update_ui is Working..
But for Tool bars It is not Working..
May be my approach might be wrong.. :=((
Pls Suggest me some help
Thanking u in advance..
Samir
|
|
|
|
|
Hi Samir,
I would recommend building a debug version of your DLL and then executing your application which utilizes the DLL. You can then attach the debugger to the process and step through the menu loading process. I still believe my original assessment will be true. In other words I believe that the menu resources are not found.
Can you test my theory with the debugger and post the results back here?
Best Wishes,
-David Delaune
|
|
|
|
|
HI,
Thanks for your kind Suggestion i have tried it. i still get the resources for menu.. but the updateCommand_ui Does not appear for toolbar.
one more thing i have noticed is that a)When i make Call to the Dll, before the Entry point function is called the application goes to the Initinstance of the App where i m creating the Object of mainFrm and then assigning it to main win thread.. here it is noticed that the MainFrm Object created goes out of scope though i am still in the function. Is it something to do with the caller thread?
Thanks
Samir
|
|
|
|
|
HI David,
Thanks For your Kind Response.. i Finally found a solution to it.. i.e i posted WM_IDLEUPDATECMDUI on the main thread.. and it helped me.. i also used
LRESULT CMyDialog::OnIdleUpdateCmdUI(WPARAM wParam, LPARAM lParam)
{
if (IsWindowVisible())
{
SendMessageToDescendants(WM_IDLEUPDATECMDUI, wParam, lParam);
}
return 0L;
}
as i had many toolbars..
Thanks Again
Samir Satardekar
|
|
|
|
|
Hi,
Recently we have a new hardware that came with USB interface and is written as COM object library with a .tlb and .lib file along with .h(which has only #define constants) file. I create an MFC project with ATL support and using this library it was easy to program in VC++ by including .h file and importing .tlb file and declaring a CComPtr and at last using CoCreateInstance to create a instace of the comptr. But this is all not possible in CVI. Is there any way to create a DLL with ATL support that can be used in CVI (which is basically a C compiler). I tried creating a ATL DLL and using it in CVI and it came up with a lot of errors in WINNT.H or is there any other way to interface with this hardware??
thanks,
-PNT
PKNT
|
|
|
|
|
CVI = Labview CVI, yes ?
I did some looking at the manual and it wasnt obvious - a search through google revealed this book "Advanced Topics in LabWindows/CVI"
by Shahid F. Khalid which was illustrating how to use the 'DataSocket' object - which is an ActiveX control so that seemed 'hopeful'
Other than that CVI seems to like 'simple c-style Dlls' but Ive only had a very quick look, so dont be discouraged .. thought - can you create a 'proxy' dll that exposes simple methods to Labview/CVI yet interfaces to your USB COM interface on 'the other end'
'g'
|
|
|
|
|
I m trying to change the bitmap of an exe externally without making any changes in resource file(.rc) of that application.now i m able to retrieve the bitmap file data as well as exe bitmap data, but unable to change exe bitmap.it errazing original bitmap of an exe, when i m calling UpdateResource function of MFC.
|
|
|
|
|
Are you looking for a temporary change? Something does by SetIcon API? Are you trying to call UpdateResource from an external application?
If doesn't have the source code of that application or not planning to update any source of that application, Probably you may need to Inject some DLLs to application which can load and update the icon at runtime. Update resource function will make permanent change in your exe.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
i dont want to change icon of an EXE, i want to change Bitmaps for an EXE externally, without making any changes in the application of that EXE.
|
|
|
|
|
Look into API call hooking and DLL injecting as Sarath also suggested. Try hooking the LoadBitmap or LoadImage calls and for the bitmap IDs you want to change load different bitmaps and return those. Good luck.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Although it's a pretty easy task once accustomed to the type of work, you may find the solution a little offputting.
All you have to do is add a bitmap to the exe file using a EXE-file resource editor, then modify the code that loads the original bitmp so that it now loads the new bitmap (with it's new resource ID)
The first task you can do with Reshacker, the second you'll need OllyDbg or any other dissassembler/hex-editor combo. Generally speaking, each time your program loads the bitmap resource, it makes a call to LoadResource. One of the arguments for this call is the resource ID of the resource to load.
You need to find all instances of this old resource-ID and change them to the resource-ID of the new bitmap. (You can directly edit the dissasembly, and save changes back to an exe file)
|
|
|
|
|
I have C++ source code as following:
CString rcvBuff;
LPTSTR lpBuff;
lpBuff = rcvBuff.GetBuffer(300);
I want convert to standard C language. Please help me.
Thank you verry much!!!!
thank you for helping
|
|
|
|
|
Hi,
is (char*)malloc(301); what you are looking for?
if so, don't forget to call free() eventually.
|
|
|
|
|
Hi Luc Pattyn, thank you for your help.
But I still haven't know yet.
Do you mean:
rcvBuff = (char*)malloc(301);
Then... the relation of 'lpBuff' with 'rcvBuff'?
Please help me!
thank you for helping
|
|
|
|
|
Hi,
in C a string is just a pointer pointing to a number of bytes containing (or intended to contain)
a sequence of characters ending on a NULL; so either you already have a string, and hence you have
the pointer, or you need to create one, and then you call malloc.
|
|
|
|
|
hi Luc Pattyn,
Thank you for yor help.
I have a question.
rcvBuff = (char*)malloc(301);
Then
free(rcvBuff);
is this right? I think that 100 and 300 are related.
please help me!
thank you for helping
|
|
|
|
|
Hi,
I don't know what your 100 would stand for.
to undo a malloc you call free() without arguments; you can only free the entire buffer, which should be OK.
There are more specialized functions but I have never needed them at all.
You know there is such a thing as documentation that tells you all the details you may ever need...
|
|
|
|
|
Hi Luc Pattyn,
Anyway, thank your for your help .
thank you for helping
|
|
|
|
|
Hello,
Is there any reason why dynamic_cast<> is turned off in my MFC projects by default?
I always get (in Debug and Release builds).
warning C4541: 'dynamic_cast' für polymorphen Typ 'CWnd' mit /GR- verwendet; unvorhersehbares Verhalten möglich
Is there any reason to not add the /GR switch?
Why is this not done by default?
The whole C-style casting with objects in the MFC code itself is really bad coding style anyway (C-style casts should not be used any more in C++)
Regards,
Niki
|
|
|
|
|
What about documentation [^]?
It looks like you're using Visual Studio 2003 or earlier.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Heh. I was wondering how old the Visual Studio version had to be.
I can't remember the last time RTTI wasn't enabled by default.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|