|
Hi Guys
i using DeviceIoControl to block a external hard drive by using flowing code
m_hDevHndl = CreateFile(szUc,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if(m_hDevHndl != NULL)
{
if(DeviceIoControl DevHndl,FSCTL_LOCK_VOLUME,NULL,0,NULL,0,&junk,NULL))
But DeviceIoControl is failing
with regards
Ryk
|
|
|
|
|
First, CreateFile(...) is supposed to return INVALID_HANDLE_VALUE when things go wrong, not NULL , so you need to correct that to ensure that the device is really being opened.
Second, you should be checking the error code returned from GetLastError() whenever a function fails, so you can try to determine exactly what went wrong.
Correct those two mistakes and then see what is really going on.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hi
I'm trying to add a picture in my excel automation code.All i need to do is ,say i have an image whose path is stored in a variable ,say strFileName, then i have to display this image in an excel sheet through my code.I tried doing something like this:
Pictures pict;
pict.Insert("c:\\tree.gif", covOptional);
pict.Select(covTrue);
pict.CopyPicture((long)1,(long)-4147);
range=sheet.GetRange(COleVariant("A1"),COleVariant("A1"));
range.Select();
sheet.Paste(covOptional,covFalse);
But,on running the application this would only display the above text in the column beginning from A1 upto A7. I dunno what to do.I looked at the the following website :
http://www.codeproject.com/com/ComExcelImages.asp
But this code was too complicated and i don't really need this level of complexity in my code.
Can someone help me??
Thanks a lot,
Priyanka
|
|
|
|
|
Hi,
I am using Visual Studio 2005 and I have made a MFC application(Use MFC in a Shared DLL) and test it on same machine then it works fine but when i test that on other machine i get the error "This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.", but when i change the configuration of application (Use MFC in a Static Library), then it works fine. I thought that might be the problem that MFC Redistributable are not installed, but I have tested that on machine where visual studio 2005 is installed and i am getting the same error, does any one know about it.
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
"English is my second language, so please don't mind if i do some grammatical or spelling mistakes in my messages."
|
|
|
|
|
I think you answer your question already You are going to have to install the missing mfc dlls that are required for your app to run!
Do a search on the MS site for MFC redistributable and then download them and get them installed on the other pc and see if that doesn't fix your problem!
There might be a few dlls missing, one way for you to find out what dlls are loaded by your app is to use the dump bin utility, or you can go to the sysinternals site and download their cool tools and either use the 'ListDLLs' utility or "Process Explorer" when your mfc app is running in your development environment.
|
|
|
|
|
Thanks for the reply.
I have checked that MFC's binary with Dependency Walker, it doesn't show any of the dependency error, the only error it shows the same which i have mentioned "This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.", I have tested my application on multiple machines where VS2005 is installed, but still i see the same error.
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
"English is my second language, so please don't mind if i do some grammatical or spelling mistakes in my messages."
|
|
|
|
|
Mushq wrote: I have tested my application on multiple machines where VS2005 is installed, but still i see the same error.
But if you go one step further and build the app on those machines, do you still get the error?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: go one step further and build the app on those machines
Thanks a lot!
I build the app on one more machine, there it worked fine and as well as on another remote machine, so i think there is some problem in visual studio settings of my machine.Now i have got my app in a working form.
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
"English is my second language, so please don't mind if i do some grammatical or spelling mistakes in my messages."
|
|
|
|
|
|
Seeing that you are not getting errors about missing DLLs or missing ordinals, and the fact that the word "configuration" is mentioned, my first guess would be something up with your manifest (<appname>.exe.manifest file, or embededd into the resources), if any.
Have you looked into the Event Viewer to see if any more detail is available (it might be a DLL problem, after all)? SxS (Side By Side) problems can raise that message as well (which leads me back to the manifest ).
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
I was just about to add that possibly it has something to do with no menifest file / information, or something along that line
Would be nice if our friend could report back on this as I am curious as to what his problem really is? If he can go back to the offending PC, build the app with the manifest imbedded and run it on the other PCs to see if things are working fine this time.
|
|
|
|
|
Are you trying to run a Debug Build version on the Other Machine?
Debug Versions will only run on which have a suitable Compiler installed. The Debug Version tries to link to various DEBUG Dll's which are installed on your machine as part of you installing MSVC2005. Off the shelf XP Machines would not have these DLL's, hence a Problem!
LateNightsInNewry
|
|
|
|
|
Thanks for reply.
I have built my app in release mode, any way I got the work around of my problem that I build my app from other some other machine then it works fine on remote machine. I think there is some problem in visual studio settings of my machine.
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
"English is my second language, so please don't mind if i do some grammatical or spelling mistakes in my messages."
|
|
|
|
|
Hi all:
I am really confused about the meaning of ^ in VS2005. I see many programs declared as something like:
String^ xxx;
MyClass^ yyy;
Can anyone explain it to me please?
Thanks very much!!!
Asura
|
|
|
|
|
this is the new C++/CLI format for managed pointer, or reference (I think).
Ask in the "C++/CLI" forum for a better answer.
|
|
|
|
|
It represents a handle.It shows a handle to managed object.Poniters are with * but handles with ^.If you use of pointers then you must use of delete else you will have a leak but for handles its optionly.
|
|
|
|
|
Does it mean handle is just another way of declaring a pointer? Is that right?
Asura
|
|
|
|
|
In totally handles are different of pointers.I think I know a good site for you about C++/CLI and you will be find your answer and other answers that maybe you have a question for them.see here[^];)
|
|
|
|
|
im trying to get the WM_CHAR message and this set up is not doing it.
i have an edit text box in my window and all im getting is the keydown message when i type to it.
LRESULT CALLBACK GetMsgProc(int code, WPARAM wParam, LPARAM lParam){<br />
if(code == HC_ACTION){<br />
MSG* pMsg = (MSG*)lParam;<br />
if(pMsg->message == WM_CHAR){<br />
int i=0;<br />
i = i +10;
}<br />
}<br />
<br />
return CallNextHookEx(g_KeybdHook, code, wParam, lParam);<br />
}<br />
hook in main:
g_KeybdHook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, 0,GetCurrentThreadId());
thanks
|
|
|
|
|
lParam is not a MSG pointer in a keyboard hook proc. See KeyboardProc Function[^].
It seems to me it would be simpler to subclass the edit control than to use a keyboard hook.
Safe Subclassing in Win32[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
hi mark, im using "WH_GETMESSAGE" one of the options here and i should be dealing with this GetMsgProc Function right?
obviously not since is not working
what tells you that im dealing with "keyboard hook proc", more importantly how do i fix it.
im practicing to write a dll so i want to get my head around this hooking business.
Thank You
|
|
|
|
|
Lamefif wrote: im using "WH_GETMESSAGE"
Got it. I apparently can't read
Your code works for me. What's going wrong on your end?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
i cleaned it up alot due to experimenting lol but this is it.
CODE
|
|
|
|
|
Try this message loop:
g_KeybdHook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, 0,GetCurrentThreadId());
while (GetMessage(&msg, 0, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
UnhookWindowsHookEx(g_KeybdHook);
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|