|
Hi Mark Salsbery
Service is running under system account, and i want example.exe to run under user account through that service, in vista.
|
|
|
|
|
If it's the LocalSystem Account, then it should have the
SE_TCB_NAME privilege, and that privilege should be enabled.
It may not be enabled by default in Vista though, although I can't find
this documented.
Maybe try enabling the SE_TCB_NAME privilege...see:
Enabling and Disabling Privileges in C++[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have used following function for drawing close button on my control bar.
But it is showing like a default windows close button.
dc.DrawFrameControl(m_rectClose, DFC_CAPTION, DFCS_CAPTIONCLOSE | DFCS_FLAT );
How can i draw minimize , restore and close buttons which should change its background.As i change the color of controlbar the background
color of close button also to be changed.
Can any one tell which is the best procedure?
|
|
|
|
|
Are you having problems because your application is themed, or because you are doing custom drawing of the GUI elements? If the former, see if using the DrawThemeEdge(...) function (and/or other Theme-related functions) helps you out.
Otherwise you may have to draw the element manually.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></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! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hello everyone,
From the definition of working set, it is a subset of virtual pages resident in physical memory -- from book Windows Internals. It means working set could not be larger than virtual memory (subset relationship).
But the following simple code on Windows Server 2003 proves (if you monitor virtual bytes counter and working set bytes conuter from perfmon), if we do not unmap the page map file, the working set will continue to increase (and much larger than virtual bytes) until we unmap it.
Take a breakpoint before following code section,
for (sectionIndex = 0; sectionIndex < size/allocSize; sectionIndex++)
{
if (map [sectionIndex])
{
UnmapViewOfFile(map [sectionIndex]);
}
}
Any ideas? Does my code break the definition of working set? Why working set is much larger than virtual bytes?
int main(int argc, char* argv[])
{
LARGE_INTEGER start,end;
LARGE_INTEGER freq;
QueryPerformanceCounter(&start);
QueryPerformanceFrequency(&freq);
MEMORYSTATUS memstat;
void** map;
int sectionIndex = 0;
memstat.dwLength = sizeof(memstat);
GlobalMemoryStatus(&memstat);
long long size = 512*1024*1024;
HANDLE mapping =
CreateFileMapping(NULL,NULL,PAGE_READWRITE|SEC_COMMIT,(DWORD)(size << 32),DWORD(size),NULL);
if (mapping)
{
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
const int allocSize = sysInfo.dwAllocationGranularity;
GlobalMemoryStatus(&memstat);
void *mem = new char[allocSize];
memset(mem,0x11,allocSize);
map = (void**) new char [sizeof(void*) * size / allocSize];
for (int i=0; i < 10; i++)
{
sectionIndex = 0;
for (long long offset=0; offset<=size-allocSize; offset+=allocSize)
{
map [sectionIndex] =
MapViewOfFile(mapping,FILE_MAP_WRITE,(DWORD)(offset<<32),(DWORD)offset,allocSize);
if (map [sectionIndex])
{
memcpy(map [sectionIndex],mem,allocSize);
}
sectionIndex++;
}
for (sectionIndex = 0; sectionIndex < size/allocSize; sectionIndex++)
{
if (map [sectionIndex])
{
UnmapViewOfFile(map [sectionIndex]);
}
}
GlobalMemoryStatus(&memstat);
sectionIndex = 0;
for (long long offset=0; offset <= size-allocSize; offset+=allocSize)
{
map [sectionIndex] =
MapViewOfFile(mapping,FILE_MAP_READ,(DWORD)(offset << 32),(DWORD)offset,allocSize);
if (map [sectionIndex])
{
for (int t=0; t < allocSize; t++)
{
if (((char *)(map [sectionIndex]))[t]!=0x11)
{
OutputDebugString("Memory read failed\n");
}
}
}
UnmapViewOfFile(map [sectionIndex]);
}
GlobalMemoryStatus(&memstat);
}
QueryPerformanceCounter(&end);
GlobalMemoryStatus(&memstat);
printf("Time %.3f\n",
double(end.QuadPart-start.QuadPart)/double(freq.QuadPart));
CloseHandle(mapping);
delete[] mem;
GlobalMemoryStatus(&memstat);
}
return 0;
}
thanks in advance,
George
|
|
|
|
|
Hi All,
I am developing one 'Text editor' kind of application. I want to put a menu item for showing the line numbers.
Can any one please tell me how can i show the line numbers ???
Regards,
Sanjeeva K Kanakam.
|
|
|
|
|
Erm... you're not going to get any useful answers without giving more information.
How are you displaying the text? If you're drawing it yourself, then I'm sure you have the skill to use TextOut / DrawText and turn a number into a string.
If you're using a rich text control, then have a look at some of the articles on CP. I remember Mr Rosengren's article have line numbers in them.
If you're doing another way, then you'll still need to tell us.
Good luck,
Iain.
|
|
|
|
|
Will your editor be based on some sort of an edit control?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Can you more explain,please?
|
|
|
|
|
Does anybody know how to work with libww(the open source w3c library for network programming)?
I'm trying to use it to build a HTTP proxy server, since it provides a lot of APIs for parsing,generating and handling HTTP.
Any help will be really appreciated..
|
|
|
|
|
Hi all,
Still I'm learning C++ and I'll try my best used most better ways in my works.
When I'm coding, I mean use of try, catch or if, else etc..., always used a single line of code. Here it is...
cout << "Error. GetLastError reports " << GetLastError() << endl;
In simple word find the error code and correct way. If I'm working on MFC, cout replaced by a message box.
My question is what is the best way to display errors for users. Displaying error codes is not prefer for users. Is that a separate section in C++, handling errors/exceptions.
I appreciate your help all the time...
Eranga
|
|
|
|
|
This kind of error reporting is simple and clean, well suited for the developer.
Usually the user expects a more friendly approach, like a text message, anyway I suggest you to always report the error number together with such message.
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.
[my articles]
|
|
|
|
|
CPallini wrote: This kind of error reporting is simple and clean, well suited for the developer.
Yes it is. All the time I use it and depend on that, and try to corrected errors as much possible.
CPallini wrote: Usually the user expects a more friendly approach, like a text message
That is why I really looking for it. I found on MSDN FormatMessage function used in Windows. But seems it is more complicated at the time for me. I'll try to figure it out.
CPallini wrote: I suggest you to always report the error number together with such message.
Ok, actually there is only a word "Error" depend on the code I change it, "Error in opening file." or something like that.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: That is why I really looking for it. I found on MSDN FormatMessage function used in Windows. But seems it is more complicated at the time for me
You're right. Luckily enough, they give sample code using it.
http://msdn2.microsoft.com/en-us/library/ms680582(VS.85).aspx[^]
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.
[my articles]
|
|
|
|
|
Yep....
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: But seems it is more complicated...
What's complicated about calling one function to retrieve a message?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Well, to his (and mine) justification, I have to say FormatMessage hasn't the most appealing prototype I ever seen.
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.
[my articles]
|
|
|
|
|
Eranga Thennakoon wrote: Displaying error codes is not prefer for users.
According to me users are most probably not bothered about exact the reason behind the error. So what I used to do was telling the user about failure happened in simple sentence and add some message that is helpful for the developer.
For example, see this error message.
Fatal Error<br />
Error: Could not load the image file.<br />
Failed to load the image in CMainWindow::InitInstance.
What I noted that, user who is getting the error will inform the developer (ofcourse not directly) that the program ceased to work and shows a message as ...
So the developer got a chance to identify the problem while sitting in his seat.
PS: This may not be feasible for large scale productions. But for small scale of productions I have found it is useful.
|
|
|
|
|
That is right. Most of the time users are not worried about the error message, only looking available options like Retry, Abort, Cancel etc...
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: only looking available options like Retry, Abort, Cancel etc...
|
|
|
|
|
I would suggest displaying both the error code and the error description for a couple of reasons. First, IME, numeric error codes are likely to be read back to a support person correctly as opposed to a possibly long error message text. Some users find it insulting when you have to keep asking them to "read back the error message exactly as shown," and even then may skip a word or paraphrase.
Second, if being used on a non-English version of Windows, the error message text may be unfamiliar to your support staff, but the error code will remain the same.
I tend to format errors as follows: [ActionAndOrContext]:[ErrorCode]-[ErrorMessage] . Examples:
Unable to open the data file: 5-Access is denied.
Unable to process the data file: 8-Not enough storage is available to process this command. If you are writing a Windows GUI application (using MFC or not), I would suggest using Message Boxes.
Lastly - do not forget (Correct) logging. Having an accurate log of what took place before an error is invaluable.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></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! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Ok thanks a lot.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Hello everyone,
What is wrong with the code, I just want to allocate an array of 100 void* pointers.
int main()
{
void** p;
p = new (void*) [100];
return 0;
}
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C2143: syntax error : missing ';' before '['
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C3409: empty attribute block is not allowed
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C2143: syntax error : missing ']' before 'constant'
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C2143: syntax error : missing ';' before 'constant'
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C2143: syntax error : missing ';' before ']'
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C2143: syntax error : missing ';' before ']'
thanks in advance,
George
|
|
|
|
|
Just remove the paranthesis.
|
|
|
|
|
Thanks Cedric,
Your solution works! Why adding an additional () will block compiler?
regards,
George
|
|
|
|