|
Hi All
I hava a problem to read specific string from file.I am useing CStdioFile class.Code is here
[code]
CString ab;
CStdioFile file;
if (file.Open(_T("\\App.txt"), CFile::modeRead | CFile::modeNoTruncate))
{
while(file.end)
{
file.ReadString(ab);
}
file.Close();
}
[/code]
In my line is like this
Mr. As 10 Developer
Mr. PC 19 Analyst
Now i want to read Mr. As and Mr. Pc Name only.How can i read this.Plz help me
modified on Friday, October 17, 2008 3:47 AM
|
|
|
|
|
lpVCcode wrote: CSting
Wow, a MFC class wrapping the former Police's singer.
Well, you have to parse the single lines, using, for instance CString::Tokenize [^].
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: Wow, a MFC class wrapping the former Police's singer.
I'm so glad I wasn't drinking coffee when I read that
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You can use of CString::Find.
|
|
|
|
|
lpVCcode wrote: Now i want to read Mr. As and Mr. Pc Name only.How can i read this.
Use AfxExtractSubString() in ab .
"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
|
|
|
|
|
is there some way to check status of printer(selected from CPrintdialog selection) means either its Ready, offline or unable to connect with server ??
like GetDeviceName() gives name of printer but how to check its status.........
pls help
|
|
|
|
|
|
thanks for da reply i will check it
|
|
|
|
|
ani_ikram wrote: is there some way to check status of printer...
What about calling GetPrinter(hPrinter, 2, ...) ?
"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 reqirement is to change admin rights user to limited account user. I tried to change admin rights to limited user account using NetUserSetInfo(). But wasnt succeeded in that.
so please help me out in this scenario. How would I accomplish it?? Any help would be greatly appreciated.
Thanks.
Hemang
|
|
|
|
|
Hemang Raval wrote: I tried to change admin rights to limited user account using NetUserSetInfo(). But wasnt succeeded in that.
What did NetUserSetInfo() return?
"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
|
|
|
|
|
It has returned error code 87. Having been referred to MSDN, i came to know that this error code indicates that one of the functions parameter is invalid. But i am not having an idea about which parameter i am passing wrong.
Any clue?? Your help would be greatly appreciated.
Thanks
Hemang
|
|
|
|
|
|
void ChangeUserPrivilege(LPWSTR csUser, DWORD csPrivilege)
{
NET_API_STATUS nStatus;
USER_INFO_1 ui1005;
DWORD dwLevel1005 = 1005;
DWORD dwPrivilege = 0;;
wchar_t *pswzUser = csUser;
if(csPrivilege == 2) dwPrivilege = USER_PRIV_USER;
ui1005.usri1_priv = dwPrivilege;
nStatus = NetUserSetInfo(NULL,pswzUser,dwLevel1005,(LPBYTE)&ui1005,NULL);
if(nStatus != NERR_Success)
// MessageBox(hwnd, (LPCWSTR)"Failed", (LPCWSTR)"Test", NULL);
fprintf(stderr, "NetUserGetinfo failed with error: %d\n", nStatus);
}
I am using above code to change admin rights user to limited rights user. Is it possible with this code.
Thanks
|
|
|
|
|
Hi
I need to get the name of the local system Administrator (System is in the domain). As that name however appears in the ControlPanel->"UserAccounts" list or ControlPanel->AdministrativeTools->ComputerManagement->LocalUser and Groups->Groups and clicking on "Administrators" Group, I am trying to list out all the users under "Administrators" Group and for this purpose I am using NetLocalGroupGetMembers() and including lmaccess.h file. But I am getting the linker error "error LNK2001: unresolved external symbol _NetLocalGroupGetMembers@32". Doesn't this header file "lmaccess.h" come with Visual Studio?
Using ADSI, I can get the members of an "Administrators" group (local system) , however, that list doesn't include the name of the the local system administrator , who is a member in the domain.
Is there anyother alternative mechanism/function to get the local system Administrator Name?
Thanks in Advance.
Taruni
|
|
|
|
|
You need to add Netapi32.lib to your project.
If you are using VS6, take
project settings->Link Tab and in that you can find a edit box "Object/library modules". Enter Netapi32.lib in it.
|
|
|
|
|
Thank You Naveen. The linker error has gone.
Is there any other alternative function to get the local system administrator?
Taruni
|
|
|
|
|
Whats wrong with this function?
|
|
|
|
|
I am unable to understand as how to enumerate the users list.
Taruni
|
|
|
|
|
sample code:
LPLOCALGROUP_MEMBERS_INFO_1 pstMembersInfo = 0;
DWORD entriesread = 0;
DWORD totalentries = 0;
if( 0 != NetLocalGroupGetMembers( NULL, _T("Administrators"), 1, (LPBYTE*)&pstMembersInfo,
MAX_PREFERRED_LENGTH, &entriesread, &totalentries, 0 ))
{
AfxMessageBox( _T("NetLocalGroupGetMembers failed !"));
return ;
}
for( DWORD dwIdx =0; dwIdx < entriesread; dwIdx ++ )
{
AfxMessageBox( pstMembersInfo[dwIdx].lgrmi1_name );
}
NetApiBufferFree( pstMembersInfo );
|
|
|
|
|
Thank you Naveen for the great help.
Taruni
|
|
|
|
|
What does that have to do with using another function? Regardless of how the list is obtained, wouldn't you still need to iterate through it?
"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
|
|
|
|
|
Taruni wrote: I am getting the linker error "error LNK2001: unresolved external symbol _NetLocalGroupGetMembers@32". Doesn't this header file "lmaccess.h" come with Visual Studio?
Yup sure does, that's why it's a linker error and not a compile error that you're getting.
You'll have to link the netapi32.lib to get access to the function.
Yeah, what Naveen said.
|
|
|
|
|
Is it possible (and a rationale design) to show a menu on right-click of the list box item of a combo box and remove
the item by clicking a menu item say 'Remove Item'.
Any similar help material/article are welcome.
Thanks in Advance.
|
|
|
|
|