|
I got the root cause of the issue.
Pausing the service is causing the service thread to be suspended with the statement SuspendThread(threadHandle);
So an attempt to stop the service from a paused state with SERVICE_STOP_PENDING was failing with error
Error 1053: The service did not respond to the start or control request in a timely fashion.
I had to resume the service thread before the stopping the service.
Thanks, Sunil
|
|
|
|
|
Is it possible to change linked-text color for CRichEditCtrl?
.
|
|
|
|
|
Hello,
Get this CRichEditCtrl in CDC, then use SetTextColor to set the color of the text.
Search in MSDN for reference.
Regards,
A. Gopinath.
|
|
|
|
|
Hi,
I am having the follwoing CString "0000122334" and I need to remove the starting zeros from the string.
Kindly help.
Thanks in Advance.
|
|
|
|
|
TrimLeft("0");
call this CString member function.
|
|
|
|
|
Just a sidenote to what Prasann Mayekar said: if your string contains only zeroes, "0000", trimming it will result in an empty string, also, if you can have fractions, like "0.45", then trimming will result in ".45".
> 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<
|
|
|
|
|
There can be various ways of doing this:
1. Use the Replace method from the CString class
2. Iterate through the characters in the string, until you get a non zero element. Store the index here and use the TrimXYZ function from the CString class.
You talk about Being HUMAN. I have it in my name
AnsHUMAN
|
|
|
|
|
I have an application that upon startup does an automatic software update. It checks a folder if it contains any files, and if found, copies those files over to their respective target folders.
Now suddenly this updating does not work anymore. It copies the file to the target folder, but the result is not a file in the target folder, but a sub folder with it's name as the source file's name.
Ex.
I have a file in my upgrade folder:
C:\Program\Upg\Logo.jpg
This file needs to be copied to
C:\Program
So my program does
CopyFile(strSource, strTarget, FALSE)
with
strSource = "C:\\Program\\Upg\\Logo.jpg"
strTarget = "C:\\Program\\Logo.jpg"
After the copy I end up with a sub-folder in C:\Program called Logo.jpg\ which is empty, instead of a file called Logo.jpg in C:\Program
I then hard coded the paths like:
CopyFile("C:\\Program\\Upg\\Logo.jpg", "C:\\Program\\Logo.jpg", FALSE);
but it does exactly the same
I then made an empty new console application with the hard coded CopyFile call as above and it works fine, ie. Logo.jpg is copied from the Upg folder to C:\Program
I tried playing with the project settings, stack/heap sizes, etc, but my application does not copy the file !
Any ideas ?
|
|
|
|
|
is your CopyFile return true or false?? If false than use GetLastError() to check the error information.
"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 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
|
|
|
|
|
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.
.
|
|
|
|