|
toasttime wrote: Say I have a string that is read from a .csv file and looks like
word1,word2,word3,word4
how would I isolate, say, word3, and have the value in a seperate variable.
You need to tokenize this string based on a separator char (for you it will be ',').
You can use either Tokenize function of CString or _tcstok_s . Then you can do additional operations based on the tokens, like compare and decide whether it's the string that you were looking for.
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
CString's Tokenize method helps
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
I want to get System login detail.
Such as i want to get Which user(administrator or user),user type etc
How to get this in VC++
|
|
|
|
|
pooja_friends wrote: Which user(administrator or user
IsUserAnAdmin()[^]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
can you give me a sample code please
|
|
|
|
|
It is a simple function, takes no parameters and returns TRUE if the user is an Administrator or FALSE if not.
if(IsUserAnAdmin())
AfxMessageBox(_T("User is an administrator"))
else
AfxMessageBox(_T("User is not an administrator"))
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
You need sample code for using a function that takes no arguments and returns a simple type. Are you really a senior developer?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
pooja_friends wrote: Such as i want to get Which user(administrator or user),user type etc
You can use CheckTokenMembership . Here is the link to this in MSDN -> http://msdn.microsoft.com/en-us/library/aa376389(VS.85).aspx[^]
Source for IsUserAdmin is shown here, you can customize it for your needs.
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
'IsUserAnAdmin' : undeclared identifier
I have got this error
|
|
|
|
|
pooja_friends wrote: 'IsUserAnAdmin' : undeclared identifier
MSDN says that you'll need to link to shell32.lib and #include <shlobj.h> to use this function.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
how can i link shell32.lib
|
|
|
|
|
pooja_friends wrote: how can i link shell32.lib
#pragma comment(lib, "Shell32.lib")
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
My code
#include "stdafx.h"
#include "useradmin.h"
#include "useradminDlg.h"
#include <shlobj.h>
#pragma comment(lib, "Shell32.lib")
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
void CUseradminDlg::OnOK()
{
// TODO: Add extra validation here
if(IsUserAnAdmin())
AfxMessageBox(_T("User is an administrator"));
else
AfxMessageBox(_T("User is not an administrator"));
CDialog::OnOK();
}
I got Following error :
**********************
77) : error C2065: 'IsUserAnAdmin' : undeclared identifier
Generating Code...
Error executing cl.exe.
what is problem
|
|
|
|
|
pooja_friends wrote: 77) : error C2065: 'IsUserAnAdmin' : undeclared identifier
Probably your SDK is too old. See question no. 2.2 in this FAQ article[^]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
TCHAR infoBuf[INFO_BUFFER_SIZE];
DWORD bufCharCount = INFO_BUFFER_SIZE;
CString s;
// Get and display the name of the computer.
bufCharCount = INFO_BUFFER_SIZE;
if( !GetComputerName( infoBuf, &bufCharCount ) )
::MessageBox(0,"GetComputerName","Cannot computer name",0);
s.Format("%s", infoBuf );
::MessageBox(0,s,"Computer Name",0);
// Get and display the user name.
bufCharCount = INFO_BUFFER_SIZE;
if( !GetUserName( infoBuf, &bufCharCount ) )
::MessageBox(0,"GetUserName","Can not read user name",0);
s.Format("%s", infoBuf );
::MessageBox(0,s,"User Name",0);
This code display system name and user name correctly
I want user account type (administrator or limited)
|
|
|
|
|
pooja_friends wrote: I want user account type (administrator or limited)
I have already answered this query.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Hi friend,
I am using this code in my system to identify What is computer name & currently who is using it.
<code>/////////////////////////////////////////////////////////////////////
DWORD i;
TCHAR infoBuf[INFO_BUFFER_SIZE];
DWORD bufCharCount = INFO_BUFFER_SIZE;
// Get and display the name of the computer.
bufCharCount = INFO_BUFFER_SIZE;
if( !GetComputerName( infoBuf, &bufCharCount ) )
::MessageBox(0,"GetComputerName","Cannot computer name",0);
s.Format("%s", infoBuf );
::MessageBox(0,s,"Computer Name",0);
// Get and display the user name.
bufCharCount = INFO_BUFFER_SIZE;
if( !GetUserName( infoBuf, &bufCharCount ) )
::MessageBox(0,"GetUserName","Can not read user name",0);
s.Format("%s", infoBuf );
::MessageBox(0,s,"User Name",0);
/////////////////////////////////////////////////////////////////////
</code>
Have Good Luck...
Jagdish Bhimbha
S/W Developer
|
|
|
|
|
BOOL IsUserAdmin(VOID)
/*++
Routine Description: This routine returns TRUE if the caller's
process is a member of the Administrators local group. Caller is NOT
expected to be impersonating anyone and is expected to be able to
open its own process and process token.
Arguments: None.
Return Value:
TRUE - Caller has Administrators local group.
FALSE - Caller does not have Administrators local group. --
*/
{
BOOL b;
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup;
b = AllocateAndInitializeSid(
&NtAuthority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&AdministratorsGroup);
if(b)
{
if (!CheckTokenMembership( NULL, AdministratorsGroup, &b))
{
b = FALSE;
}
FreeSid(AdministratorsGroup);
}
return(b);
}
I have add this function to find User account type but i got following error
CheckTokenMembership' : undeclared identifier
|
|
|
|
|
Hello...
The function CheckTokenMembership() requires following things :
Header : Declared in Winbase.h; include Windows.h.
Library : Use Advapi32.lib.
DLL : Requires Advapi32.dll
Check by including this header file.
Next solution is you can you something like :
Bool IsUserAdmin(VOID)
{
DWORD i;
TCHAR infoBuf[INFO_BUFFER_SIZE];
DWORD bufCharCount = INFO_BUFFER_SIZE;
char admin[]="Admin"
Have Best Luck this time...
Jagdish Bhimbha
S/W Developer
|
|
|
|
|
Hi all,
"Attempt to Update or Delete failed." and "Recordset is read-only"
These two error is occur when i update the record.
how can i resolve them.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
What "Connection String" did you use from?
(e.g.
"SELECT * FROM [MyTable]" )
|
|
|
|
|
i m not using SQL Queries.
i m using CRecordset derived class, and directly assign the value of database variable to my dialog variable.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
ThatsMe. wrote: how can i resolve them.
By opening the recordset as updateable.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi All,
I have a doubt in serial communication.
I am using non-overlapped io serial communication inside a thread in my application. So while coomunicating with the instrument, the thread gets blocked without blocking the application.
Now what is the difference between the above scenario and overlapped io communication?
Thanks for your reply .
|
|
|
|