|
od@ananzi.co.za wrote: It sometimes returns TRUE , but still copies the file into the empty sub-folder
It sometimes returns FALSE, but still copies the file into the empty sub-folder, GetLastError then returns 5
If GetLastError returns 5 than it means Access Denied. You do not have rights to copy data in Program folder.
1) Run your application as admin or
2) Change the property "UAC Execution Level" -> "asInvoker" to "requireAdministrator".
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
"Your thoughts are the architects of your destiny."
|
|
|
|
|
It made no difference. I also tried running the program as Administrator, but still the same.
Remember that my console application worked fine though, so I doubt that it is permissions ...
|
|
|
|
|
Error code 5 means access denied. I am not sure why this error comes.
I don't know it is working or not but before copying the file into the target file, Delete the target file using "DeleteFile".
DeleteFile(strTargetPath);
CopyFile(strSourcePath,strTargetPath,FALSE);
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
"Your thoughts are the architects of your destiny."
|
|
|
|
|
Hi,
I'm not 100% sure, but it might be caused by UNICODE-related settings.
Make sure your call to CopyFile is actually using CopyFileW. Also, you can check your compiler command line to see if it uses UNICODE option.
|
|
|
|
|
I have now also tried SHFileOperation as follows, but it also copies the file into the sub folder :
SHFILEOPSTRUCT sMove = {GetSafeHwnd(), FO_MOVE};
sMove.pFrom = strSource + _T("\0");
sMove.pTo = strTarget + _T("\0");
sMove.fFlags = FOF_NO_UI;
SHFileOperation(&sMove);
|
|
|
|
|
Hi!
How Windows XP(in general any Windows OS) identifies the currently running VC++ application?
|
|
|
|
|
|
I've created a Single Instance application using the following code:
if(NULL != ::CreateMutex(NULL, TRUE,_T("CSingleInstanceApp")))
{
long dwError = ::GetLastError();
if(dwError == ERROR_ALREADY_EXISTS)
EndDialog(NULL,IDOK);
}
I've designed one project as a template and used it to build many applications. e.g I tried to run one application named "app2" while another application named "app1" is already running. But "app2" does not run. I don't want this. "app2" should not run if and only if "app2" is already running. Otherwise it has to run normal. How to do this?
|
|
|
|
|
Create a guid by using guidgen.exe and check this code ->[^]
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
|
|
|
|
|
I solved the problem patially by following the above link. Now my problem is:
If I close one instance the other instance is also closed. How to fix this?
|
|
|
|
|
pix_programmer wrote: If I close one instance the other instance is also closed. How to fix this?
How it is possible ??
Are you using this code in InitInstance.
if (g_SingleInstanceObj.IsAnotherInstanceRunning())
return FALSE;
If you are using this code in InitInstance than another instance is not getting created but the running instance is not getting closed.
Please share your code.
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
|
|
|
|
|
I've not used the above code. I used the following code.
if(NULL != ::CreateMutex(NULL, TRUE,_T("{AFD2966D-9A83-4E3A-9C9E-CD81E96D819A}")))
{
long dwError = ::GetLastError();
if(dwError == ERROR_ALREADY_EXISTS)
EndDialog(NULL,IDOK);
}
By instance I do not mean same application instance. If I close app1, app2 is also closed. What to do?
|
|
|
|
|
pix_programmer wrote: If I close app1, app2 is also closed. What to do?
What do you mean app1 and app2?? Are you talking about instance of same application??
If CreateMutex is fail than it returns NULL and you are checking that if it is not null than you are checking GetLastError.
if(NULL == ::CreateMutex(NULL, TRUE,_T("{AFD2966D-9A83-4E3A-9C9E-CD81E96D819A}")))
{
long dwError = ::GetLastError();
if(dwError == ERROR_ALREADY_EXISTS)
{
EndDialog(NULL,IDOK);
return FALSE;
}
}
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
"Your thoughts are the architects of your destiny."
|
|
|
|
|
If I read your correctly, the name of mutex should be unique ,pass some unique string while creating first instance of app1,app2 and so on. the reason you are getting problem you are using the same mutex name for all the application.
HTH
|
|
|
|
|
WM_NOTIFY is submitted to control's parent window, is it possible to submit the message to control itself instead of its parent?
the control currently used is CRichEditCtrl.
.
|
|
|
|
|
Maybe try overriding OnChildNotify()
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
thanks, it may work even I haven't test in detail.
|
|
|
|
|
Try with ON_NOTIFY_REFLECT/ON_CONTROL_REFLECT, see here[^] for details.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
OnChildNotify() works perfectly in my case - I guess it also works fine for other controls.
|
|
|
|
|
what is good init point (message) for subclasses of controls (such as CEdit, CStatic) of a CDialog?
the init point is not on OnInitDialog(...) of the dialog, but inside subclass of controls.
OnCreate(...) of the control is not working.
what point (message) do you use when you initialize a control inside its subclass?
|
|
|
|
|
includeh10 wrote: OnCreate(...) of the control is not working.
Do you have ON_WM_CREATE() in your message map?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I use the boost regex library to parse the CString
#include "boost/regex/mfc.hpp"
But when build, the vs2008 writes "LINK : warning LNK4098: default library“MSVCRT”conflict with other library please use /NODEFAULTLIB:library"
but when I use the "/NODEFAULTLIB:library", then some obj of MFC control cannot find.
How to resovled it ?
modified on Monday, May 30, 2011 7:37 PM
|
|
|
|
|
This is just a warning, you don't have to resolve it, as a matter of fact you can disable it if you know you're overriding some of the MFC framework (which I believe the boost library does).
|
|
|
|
|
Thanks for your reply.
It's error.
When IDE cannot create "exe" file, the dialog shows "lost boost_regex-vc90-mt-gd-1_46_1.dll" if debug.
|
|
|
|
|
if it would be an error, it would say "error", not "warning"... maybe you have another error
|
|
|
|