|
This is just a work around...
make call to OpenSCManager(..) to determine admin status of User, look at this code :-
OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
if(GetLastError()==ERROR_ACCESS_DENIED)
{
MessageBox("User Is not Admin");
}
else
{
MessageBox("User is Admin");
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Remember to call CloseServiceHandle on the returned handle if the open is successful, or else you will have handle leaks in your application
The returned handle is only valid for the process that called the OpenSCManager function. It can be closed by calling the CloseServiceHandle function.
|
|
|
|
|
Blake Miller wrote: Remember to call CloseServiceHandle on the returned handle if the open is successful, or else you will have handle leaks in your application
Ohh I forget! thanks for correcting me
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
in vc++ 6.0
first I build my dll in release mode and register, it works;
then I make some modification to the code and build it in debug mode. but now if I register it again , it dosen't work, without any infomation prompted. I just can't see the program change after I modify the code. e.g. in the modification I add a button to a dialog, but button would not appear when I excute it.
how come this happen?
Thank you very much!!!
-------------------
I am learning C++ and English
|
|
|
|
|
Hello, everyone,
If I want a class object to do Upcast,
the "reinterpret_cast" is needed? why ?
Thanks a lot!
|
|
|
|
|
I do not know, using reinterpret_cast is dangerous. I would think that you would need to use dynamic_cast instead.
INTP
Every thing is relative...
|
|
|
|
|
Hello everyone,
If I want a class become a singleton class, its Construct/Destructor
should be private, protected or public?
Who can give me the answer and the reason?
Thanks a lot , best regards.
|
|
|
|
|
1st : what is "singleton class" ?
if you put the constructors of a class in private, you will never be able to instanciate your class ; if you put your constructor protected, your class will behave as an abstract class, that mean only inherited classes will be able to instanciate it thru the inheritence.
2nd : [OT] you are not obliged to put a "Ask for help: " before every question you ask on the forum.... we guess it is for help.
3rd : i advise you to learn C++ with a book or whatever you want, but a source that can provide you strong basis...
sincerely,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hello,
toxcct wrote: what is "singleton class"
It's a design pattern. I'm sure you know about it dont you.. See my other post in this thread for an implementation of a singleton class...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hello,
You should make the constructor and destructor private. In general, singletons have one member that gets a pointer to an instance of the singleton class called Instance . If only you looked on google, you would have gotten the answer more early!
class CSingleton
{
private:
CSingleton() {}
~CSingleton() {}
public:
static CSingleton* Instance()
{
static CSingleton Singleton;
return &Singleton;
}
};
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Thank you for your answer, but it's not what I want to get.
Because your example is the general case.
If treat a singleton class as a base class, other class derive from it. in this case, Constructor/Destructor?
For example:
class AAA : public Singleton<aaa>
{
}
//Singleton<aaa> is a template class
Class BBB : public AAA
{
}
|
|
|
|
|
My example was not the general case, it's how singletons are implemented! You just need to copy pase that mechanism into your class's code that you want to make a singleton. Since there's no such thing as virtual constructors, you can't derive from the singleton...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
hi
i got a project which involves 4 console programs made in C++ 6.0 SP6 and a windows app like MFC or Windows Forms under C++ 6.0 SP6 or Visual C++ .net 2003.
The deal is that i just need to set 4 buttons, each one will run one of the console apps.
i have no clue on how to do this and which would be the easiest way to achieve this.
i know how to create the app in MFC or windows forms and do something on button click, but i don't know how to run the console app.
maybe it's a really dumb question but it's something i've never done before
any help is appreciated
|
|
|
|
|
Try looking at the ShellExecute() or CreateProcess() API functions.
Software Zen: delete this;
|
|
|
|
|
Hi,
I'm running Visual C++ 6.0 MFC Document/View. I decided to initially have my menu selections begin in a disabled mode (grayed) and then enable them when needed. I used the resource editor to set the properties dialog box check for grayed, but the menu items are not grayed and I can still select them. I have commented out all references to all OnUpdateCommandUI() functions. The AppName.rc file has the menu items I defined to be grayed as grayed. Does anyone know why the menu items keep comming up in an enabled state?
Buck
|
|
|
|
|
If you have handlers ( OnCommand ) for your menu items, them will be enable, this is the default for MFC.
If you want to disable them, put back the handlers for the ON_UPDATE_COMMAND_UI and inside each one, set the value to pCmdUI to a valid value :
void CMainFrame::OnYourHandler( CCmdUI* pCmdUI )
{
pCmdUI->Enable( someBooleanValue );
}
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thanks,
It is working the way I want it to now.
Buck
|
|
|
|
|
hey this is my first time posting so forgive me for any errors.
well, heres the deal. im building a chat program. the user enters text then hit sends. the max he can enter is 1000. when he hits send, the client uses the send() func to send the msg to the server. it looks sorta like this:
<br />
send(clientSocket, buffer, strlen(buffer), 0);<br />
NOTE: at the end of the msg i added to line breaks(\n\r\n\r);
the server then recieves the message and puts it in a buffer char array with [1000]
<br />
recv(clientSocket, buffer, 1000, 0);<br />
then, for debugging purposes, the server prints out what it received.
also the strlen(buffer) is printed out.
the output for the message "hey" is:
1004 characters (already wrong)
then it prints out "hey", two line breaks, and 1000 weird chars.
my question: how do i isolate just the hey and the four chars that make up the two line breaks???
i just need an idea then i can form somethin..
thanks all!!
The Legend...
|
|
|
|
|
hello all,
i am developing an application for a client where i have only the PST lines to communicate. but the database is there in server which is far a way from my site. i need to dial the data from client application and retreive the data. how do i do that from my client application.
Could any one plz suggest me plz.
Thanking u all.
regards,
Basheer.
|
|
|
|
|
Hi everyone,
I'm working on an application that I'm trying to migrate from using a useless lib that is inspired from MFC to only use MFC, but I do not want to rewrite the whole application as I dont have time for that, atleast not now.
Problem is that this library exposes a WinMain-method and the application has it's own CWinApp-kind-of-class.
Problem is the following, I want to be able to use a proper CWinApp as parent with everything that comes with it, such as messages and windows etc.
Currently, this class is derived from CWinApp aswell as a similar class within the lib.
Only problem is that some messages are not routed as they should.
In this case, we're talking about WM_KEYDOWN.
I've looked in WinMain from this lib, and it traps the WM_KEYDOWN and it calls IsDialogMessage that is supposed to route the message. I've checked the hwnd and compared it with what I found in Spy++, and the window that it's routing this message to is the one I want, I.e. my mainframe, but the message never arrives in the msgloop, nor on a normal ON_xxx nor in PreTranslate within the mainframe.
So, question is:
Is there something I can do to ensure that all messages are routed? I've got a feeling that there's a missing thread or a thread where the object is created but not the actual thread, hence no messagepump.
I know this isnt very clear, so please flame me with details that's missing.
|
|
|
|
|
In the edit box property, I can only set TRUE for Number.
Then I only enter integer number in edit box. How I can set property to accept only decimal number into edit box ? I think I have to filter the user's typing in to edit box ?
Thanks.
MilkyWay
|
|
|
|
|
<br />
int userNumb;<br />
SendMessage(HANDLE_TO_EDIT_BOX, WM_GETTEXT, (WPARAM)10, (LPARAM)userNumb);<br />
if(userNumb<0)<br />
{<br />
}<br />
else<br />
{<br />
}<br />
the (WPARAM)10 is the max chars..(10), and the userNumb would be the input. i dont know if you can assign an int to that location, usually i use char* but since the edit box is set to numbers-only it might work!
the legend...
|
|
|
|
|
Thank you for advice. My purpose is limit the user enters wrong number into edit box.
ex:
when he enters 12.4, it is o.k, but when he enters 12T he will get message error after type "T" .
When I set property Number is TRUE I can only get 12.4, I got beep after typed "."
Any way I go around (hard way) by conversing string text from editbox to floating numb by atof(m_ebMember);
cheers.
MilkyWay
|
|
|
|
|
you'll have to overload the WM_CHAR event with OnChar() handler...
in it, you can filter the characters typed, and allow only the ones you want, such as the 10 digits plus the period ('.')... (also a sign if you like...).
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I use MFC dialog .net 2003
Could you please teach me how to implement this.
Where I overload WM_CHAR, How I call OnChar().
Thanks
MilkyWay
|
|
|
|