|
I'm leaving error checking and other dodgy stuff to you as an exercise.
const char *szEmail= "myname@mydomain.com";
std::cout<< strstr(szEmail, "@")+1 <<std::endl; Output: mydomain.com
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Rajesh R Subramanian wrote: I'm leaving error checking and other dodgy stuff to you as an exercise.
That's unfair to other competitors
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: That's unfair to other competitors
[Chris Tucker voice] I tell ya what: I am an unfair man. [/Chris Tucker voice]
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Rajesh R Subramanian wrote: [Chris Tucker voice] I tell ya what: I am an unfair man. [/Chris Tucker voice]
[Anton Chigurh voice]: You stand to win everything. Call it [/Anton Chigurh voice]
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Good try, i've got another one:
char *email="myemail@mail.com";
char *domain= strchr(email,'@')?strchr(email,'@')+1: 0;

|
|
|
|
|
Welcome to the code obfuscation club. Nah, just kidding.
Nice attempt, BTW.
[add] You know the master of obfuscations[^], right? [/add] Jus' kiddin' Carlo.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Its simple using CString class
CString sEmail, sDomain;
sEmail = "random@mail.com";
int nPos = sEmail.Find("@");
sDomain = sEmail.Mid(nPos + 1, sEmail.GetLength());
|
|
|
|
|
I am making Win32 application. My need is to determine whether current user has administrative rights or not. Also i need to check how many account exist on system with administrative rights. If no any account exist then create one with administrative rights.
Any help would be greatly appreciated.
Thanks
hemang
|
|
|
|
|
Hemang Raval wrote: My need is to determine whether current user has administrative rights or not.
BOOL IsUserAnAdmin()[^]
Hemang Raval wrote: If no any account exist then create one with administrative rights.
Windows will have at least one administrative account.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Thanks for reply. Now How would i know about the number of accounts with administrative rights. I want to create another if there exist only one admin account.
BTW, thanks for previous reply. i hope for positive reply for this question also
Regards,
Hemang
|
|
|
|
|
|
Thanks a lot again. I tried to use NetUserEnum. But it gives me the information about every account created on a machine.
My requirement is to get only number of accounts and its information which are having administrator rights.
Thanks in advance. Please help me out.
Thanks
Hemang
|
|
|
|
|
Hemang Raval wrote: My requirement is to get only number of accounts and its information which are having administrator rights.
#1) There is nothing like GetNumberOfAccounts(). However, it should be easy to count the number of accounts yourself with the information NetUserEnum() provides.
#2) For finding if an account has administrative rights, you can use NetUserGetInfo(), which I suggested in my previous post itself.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
A bunch of thanks. I got a clue from your answer and also found solution for getting number of admin account from NetGetUserInfo.
Thanks a lot again.
Regards,
Hemang
|
|
|
|
|
Hemang Raval wrote: Thanks a lot again.
Glad to be of service.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Hello to all,
I am having three questions in MFC,
1)In MDI (Multiple Document Interface) application whenever we minimize or maximize application's main outer window then which function gets called which indicates that window is maximized or minimized and where it is?
2)Is there any flag value or any other value, through which I can know the current state of my application's main window means I can know that whether my main window is in maximized state or in minimized state? and if there is such a value then how can we get that value and where?
3)Suppose my application is running and application's main outer window is in maximized state and now if I opened another non MFC application(e.g. Notepad or MS-Word) without minimizing my MFC application then on screen, that non MFC application will overcome my MFC application and now if I want to see my MFC application once again then I have to click on icon of my MFC application which is on taskbar,so as to display my MFC application once again on screen.Now my question is that, in such situation, programatically (through coding) can we check whether our MFC application is being displayed on screen or not? I mean is there any way through which we can know that whether our MFC application is being displayed on screen or not?
It is urgent so can anybody help me please?.It is really urgent
Thanks and Regards,
Anay
|
|
|
|
|
AnayKulkarni wrote: 1)In MDI (Multiple Document Interface) application whenever we minimize or maximize application's main outer window then which function gets called which indicates that window is maximized or minimized and where it is?
When ever your window is maximized or minimized, the window will get WM_SYSCOMMAND message. so handle the WM_SYSCOMMAND message of the MainFrame class to know when your window is being maximized or minimized.
AnayKulkarni wrote: 2)Is there any flag value or any other value, through which I can know the current state of my application's main window means I can know that whether my main window is in maximized state or in minimized state? and if there is such a value then how can we get that value and where?
From the wParam of WM_SYSCOMMAND, you can know that. check MSDN[^] for more details.
AnayKulkarni wrote: which we can know that whether our MFC application is being displayed on screen or not?
I guess your requirment is to know whether the current window is active window or not. In that case you can handle the WM_ACTIVATEAPP[^] message in your main frame class and track activation and inactivation of your application...
AnayKulkarni wrote: It is really urgent
hmm..Other wise I wouldnt have answered
|
|
|
|
|
Yes,it worked.Thanks a lot for your valuable help.Thank you very much.
Thanks and Regards,
Anay
|
|
|
|
|
AnayKulkarni wrote: 1)In MDI (Multiple Document Interface) application whenever we minimize or maximize application's main outer window then which function gets called which indicates that window is maximized or minimized and where it is?
Your window will receive a WM_WINDOWPOSCHANGING message.
AnayKulkarni wrote: 2)Is there any flag value or any other value, through which I can know the current state of my application's main window means I can know that whether my main window is in maximized state or in minimized state? and if there is such a value then how can we get that value and where?
Such as IsZoomed() or IsIconic() ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi All,
My exceptions are to write and read data simultaneously.As data is written it should be read by another process.For this I am using the PIPE implementation.
I wrote the following code snippet for this but it is not working
Please let know where i am wrong
Thanks
HANDLE rHandle, wHandle ;
DWORD dw ;
DWORD dw1 ;
void WriteData(LPVOID)
{
char wBuff[512];
strcpy(wBuff, "HELLO world this program for reading the pipe\n ") ;
for( ; ; )
{
Sleep(1);
if(WriteFile(wHandle, wBuff, strlen(wBuff), &dw, NULL))
{
printf("Total %d byts written\n", dw);
}
else
{
printf("Could not write the buffer Last error:%d\n ", GetLastError());
break;
}
}
}
void ReadData(LPVOID)
{
char wBuff[512];
int i =0 ;
strcpy(wBuff, "HELLO world this program for reading the pipe\n ") ;
for( ; ; )
{
Sleep(1);
if(ReadFile(rHandle, wBuff, strlen(wBuff), &dw1, NULL))
{
printf("Total %d byts read\n", dw1 );
}
else
{
printf("Could not read the buffer Last error:%d\n ", GetLastError());
break;
}
}
}
void main()
{
HANDLE aThread;
DWORD ThreadID;
int i;
if(CreatePipe( &rHandle, &wHandle, NULL, 0))
{
CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE) WriteData, NULL, 0, &ThreadID);
CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE) ReadData, NULL, 0, &ThreadID);
}
}
|
|
|
|
|
See here[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
singh_nav wrote: As data is written it should be read by another process
You're using the pipe in threads, not processes, may be that's the problem
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Thanks for the input.
Can't i use the PIPE in the same process ?
|
|
|
|
|
You certainly can. But if it's in the same process, why use a pipe at all? You can use something much simpler, even a raw array, if you like, so long as you're careful about synchronization[^].
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Thanks for the info,
Actually , I have used the array in my sample program there i have to synchronize it.
Now i want to check that how to use the pipe and will it signal to read Thread automatically as it is written.
Please provide any link or sample so i could implement it in the same process.
Thanks
|
|
|
|