|
Thanks, but is there any article on this site about this issue????
|
|
|
|
|
Here is a quick and dirty method to check whether the user *could* write to specific key
in HKLM I used for a setup program that did different levels of setup depending on the
authority of the user:
char buf [MAX_PATH];
{
OSVERSIONINFO osVer;
osVer.dwOSVersionInfoSize = sizeof (osVer);
GetVersionEx (&osVer);
bIsNT = 1 && (osVer.dwPlatformId & VER_PLATFORM_WIN32_NT);
}
bIsAdministrator = FALSE;
if (bIsNT)
{
TRUSTEE Trustee;
ACCESS_MASK AccessMask;
::BuildTrusteeWithName (&Trustee, "CURRENT_USER");
PSECURITY_DESCRIPTOR pSecDesc= NULL;
PACL pAcl = NULL;
if (::GetNamedSecurityInfo (
"MACHINE\\SYSTEM\\CurrentControlSet\\Services",
SE_REGISTRY_KEY,
DACL_SECURITY_INFORMATION,
NULL,
NULL,
&pAcl,
NULL,
&pSecDesc) == ERROR_SUCCESS)
{
if (::GetEffectiveRightsFromAcl (pAcl, &Trustee, &AccessMask) == ERROR_SUCCESS)
{
if (AccessMask & STANDARD_RIGHTS_REQUIRED)
bIsAdministrator = TRUE;
}
::LocalFree (pSecDesc);
}
if (!GetSystemDirectory (buf, MAX_PATH))
bIsAdministrator = FALSE;
else
{
::lstrcat (buf, "\\drivers");
sPathSystem = buf;
}
if (bIsAdministrator && ::GetNamedSecurityInfo (
buf,
SE_FILE_OBJECT,
DACL_SECURITY_INFORMATION,
NULL,
NULL,
&pAcl,
NULL,
&pSecDesc) == ERROR_SUCCESS)
{
if (::GetEffectiveRightsFromAcl (pAcl, &Trustee, &AccessMask) == ERROR_SUCCESS)
{
if (AccessMask & STANDARD_RIGHTS_REQUIRED)
bIsAdministrator = TRUE;
}
::LocalFree (pSecDesc);
} else
bIsAdministrator = FALSE;
}
This may give you a headstart, or at least things to search for in the Platform SDK.
Iain.
|
|
|
|
|
Thanks. You have really solved the problem
|
|
|
|
|
What I have done is something like this.
Is it the right way to do this? Please commnet.
<br />
BOOL isCurrentUserAdministrator()<br />
{<br />
<br />
DWORD dwLevel = 1;<br />
LPUSER_INFO_1 pBuf = NULL;<br />
NET_API_STATUS nStatus;<br />
DWORD nSize = 20;<br />
<br />
LPWSTR lpUsername = new unsigned short[nSize];<br />
<br />
if(!::GetUserName( lpUsername, &nSize))
return false;<br />
<br />
<br />
nStatus = NetUserGetInfo(NULL, lpUsername, dwLevel, (LPBYTE *)&pBuf);
<br />
if(nStatus == NERR_Success)
{<br />
if( pBuf->usri1_priv == USER_PRIV_ADMIN)<br />
{<br />
NetApiBufferFree(pBuf);<br />
return true;<br />
}<br />
else<br />
{<br />
NetApiBufferFree(pBuf);<br />
return false;<br />
}<br />
}<br />
<br />
return false;<br />
}<br />
<br />
|
|
|
|
|
Looks good to me. You are specifically getting a user "level", which is what your question asked.
My solution answered "can a user do 'this'?", which is a subtly different one. Sometimes users
are members of groups which have specific access to something.
Which one you use depends on the detail of why you want to know, so that is an answer best left
to your application needs.
Iain.
|
|
|
|
|
Hi all,
How a process (exe file) will be able to know path where it is residing and from where it is loaded and running?
Is there any API available?????????
Thanks for help
|
|
|
|
|
GetModuleFileName() ?
Mazy
No sig. available now.
|
|
|
|
|
|
I used the class which is derived from CControl bar
in control bar.i used the formview as a view class,form view contains other controls ,but when i resize the dock it get flicker
can any one tell me the Soln for this
thanx
|
|
|
|
|
Does anyone has some idea about setting icon(120*40) to SDI Application left corner of the title???
thanks in advance
Adi
|
|
|
|
|
Do you want to have a 120*40 icon in the title bar?
Then you would have to draw the title bar itself (WM_NCPAINT, etc).
If just would like an icon in your title bar that is a downsized version of the 120*40 icon, just call LoadImage/SetIcon.
Jens
|
|
|
|
|
hi jens...... thanks for immediate reply.....
and our requirement is as u understood.....>
Do you want to have a 120*40 icon in the title bar?
> Then you would have to draw the title bar itself (WM_NCPAINT, etc).
but my doubt is.... where to handle the WM_NCPAINT event.... neither mainframe nor view class have this Windows Message...
where shud i handle it....... and can u send me little bit detailed information for drawing......
thanks in advance......
adi narayana
|
|
|
|
|
Hmm, try the follwing:
Go to the class wizard, choose the "class info" tab, set the "Message filter" to "Window".
Now you should be able to add a message handler for WM_NCPAINT.
One of my very favourite authors, Mr. Paul DiLascia, has written a wonderful article about this, I very recommend reading it. It explains everything:
http://www.microsoft.com/msj/0697/c0697.aspx.
Hope that helps,
Jens
|
|
|
|
|
I have some doubt as to how to retrieve the Headerfooter from MS-WORD document using VC++ application. I was not able to get the appropriate functions. So, can you please tell me the solution.
I tried using the GetHeader & GetFooter member functions.But these functions are available only in the MS-WORD8 version.They are not found in the MS-WORD 9 and 2000 version.
Also I tried implementing Getheader and Getfooter functions in the word9 version,but, it is gave the following error "GetHeader Function is not the memberclass of MS-WORD9".
Is there any function to put the header and footer in an already exisiting word document using VC++.
Anna Quadros
|
|
|
|
|
I think you need Mike Dunn's FAQ.
http://207.219.70.31/cpp/cppforumfaq.asp#win_summaryinfo[^]
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Hmmm. Maybe you misread the question He was wanting the actual header/footer inside the MSWord document, not the document summary information
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
, that's what comes of not reading the question
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
I used this with Word 2000. It should get you close:
CString strFileName,
strText;
_Application app;
Documents docs;
_Document doc;
Sections secs;
Section sec;
HeadersFooters headers,
footers;
HeaderFooter header,
footer;
Range rng;
COleVariant vtOptional((long) DISP_E_PARAMNOTFOUND, VT_ERROR),
vtFalse((short) FALSE),
vtTrue((short) TRUE),
vtDoc((short) 0),
vtText((short) 2),
vtRtf((short) 6),
vtHtml((short) 8);
if (app.CreateDispatch("Word.Application") == TRUE)
{
strFileName = "MyFile.doc";
docs = app.GetDocuments();
doc = docs.Open(COleVariant(strFileName), vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional);
secs = doc.GetSections();
if (secs.GetCount() > 0)
{
for (long lSection = 1; lSection <= secs.GetCount(); lSection++)
{
TRACE("Section %ld\n", lSection);
sec = secs.Item(lSection);
headers = sec.GetHeaders();
if (headers.GetCount() > 0)
{
for (long lHeader = 1; lHeader <= headers.GetCount(); lHeader++)
{
header = headers.Item(lHeader);
rng = header.GetRange();
strText = rng.GetText();
TRACE(" Header %ld Text = ]%s[\n", lHeader, strText);
}
}
footers = sec.GetFooters();
if (footers.GetCount() > 0)
{
for (long lFooter = 1; lFooter <= footers.GetCount(); lFooter++)
{
footer = footers.Item(lFooter);
rng = footer.GetRange();
strText = rng.GetText();
TRACE(" Footer %ld Text = ]%s[\n", lFooter, strText);
}
}
}
}
docs.Close(vtFalse, vtOptional, vtOptional);
app.Quit(vtOptional, vtOptional, vtOptional);
}
|
|
|
|
|
Thanks a Lot!!
I tried the code with word 2000 version .I am getting the following error.
"GetCount is not member class of headersfooters,
GetCount is not member class of Sections"
I included Msword.h , Msword8.h and MSword9.h header files . Do I need to include any other header files.
I cannot proceed further without fixing this error
Also is there any method to put the retrieved header/footer from one document into the header/footer of another document.
Thanks and Regards,
Anna Quadros.
Anna Quadros
|
|
|
|
|
Hi,
I need to create about three to four modal dialog boxes such that when a button is pressed in the first one it leads to the next and again when a button is pressed in this it leads to the next one and so on..I am a novice in this field and I need some help in this. I tried this:
void CNewoneDlg::OnOK()
{
CDialog aboutDlg(IDD_DIALOG1);
INT_PTR pRet=-1;
aboutDlg.DoModal();
//CDialog::OnOK(); (I tried taking this off...but didnt work either)
}
This works..it leads to the next dialog box on pressing ok..
but..
void CDialog1Dlg::OnOK()
{
CDialog aboutDlg(IDD_DIALOG2);
INT_PTR pRet=-1;
aboutDlg.DoModal();
//CDialog::OnOK();
}
This doesnt lead to the next dialog box on pressing ok..I am confused, since I have used the method in the earlier function..when that can work, why cant (isnt) this?
I desperately need a help..
THANKS
Deepak Samuel
|
|
|
|
|
Instead of calling do the dialog from within the modal dialog, check the return code of the dialog when it exits to where you called it from. If it is IDOK, call the next modal dialog from tge same routine where you called the first one from
tcss
|
|
|
|
|
The best solution is to separate the dialog boxes.
Call DoModal for the first one (the program will 'wait' at this instruction til the dialog is closed), then call DoModal for the second one, and so on.
CDialog Dialog1(IDD_DIALOG1);<br />
CDialog Dialog2(IDD_DIALOG2);<br />
CDialog Dialog3(IDD_DIALOG3);<br />
...<br />
<br />
Dialog1.DoModal();<br />
Dialog2.DoModal();<br />
Dialog3.DoModal);<br />
...
|
|
|
|
|
Hi,
Thanks for the help..but I still face some problems.The first dialog box leads to the next one on pressing ok , but the next dialog box still doesnt respond to the buttons, but when I close the dialog box by clicking [x] then it goes to the next dialog box..please help me in it..
Deepak Samuel
|
|
|
|
|
Are you sure that you do not want to use a 'Wizard' style PropertySheet ?
What you describe sounds exactly like you want it.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Hi,
Thanks for your suggestion, can you help me with some example source codes..
Deepak Samuel
|
|
|
|