|
Maxwell Chen shows my case quite well. Thank you.
Danny
|
|
|
|
|
Dear fellow coders,
Im just trying to establish if the current user has the privileges to stop/start services.
Im trying to link some example code from the MDSN website into my visual C++ 6.0 project
and i get the following error. can you help?
Linking...
OLMECDlg.obj : error LNK2001: unresolved external symbol "int __cdecl
CheckTokenMembership(void *,void *,int *)"
(?CheckTokenMembership@@YAHPAX0PAH@Z)
Debug/OLMEC.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
the example code i was using was as follows:
#include <winbase.h>
#include <windows.h>
extern BOOL CheckTokenMembership(HANDLE TokenHandle,PSID SidToCheck,PBOOL
IsMember);
/*++
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 COLMECDlg::IsUserAdmin(VOID)
{
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);
}
Please note that I have also setup my linker to include advapi32.lib but
this still fails. What am i doing wrong or is there a mistake on the MSDN
webpage?
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthz/s
ecurity/checktokenmembership.asp)
Im just trying to establish if the current user has the privileges to stop/start services.
Has anyone done this before, or know how to do it in VC6.0 ?
thanks,
Paul
|
|
|
|
|
Rainos wrote:
extern BOOL CheckTokenMembership(HANDLE TokenHandle,PSID SidToCheck,PBOOL
IsMember);
This statement is unnecessary. As long as you have included winbase.h or windows.h , the function prototype already exists.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
But if I do this - it doesnt compile! - Even with winbase.h or windows.h
Do I need to have Platform SDK or a different version of VC++ for this?
|
|
|
|
|
Rainos wrote:
But if I do this - it doesnt compile!
What compiler(s) error do you get?
Rainos wrote:
Do I need to have Platform SDK...for this
It's always a good idea to be using the latest Platform SDK (dated Feb 2003) for your development.
Rainos wrote:
Do I need to have...a different version of VC++ for this?
No, version 6 is fine.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
The compiler error is simply:
error C2065: 'CheckTokenMembership' : undeclared identifier
Dont think I have Platform SDK installed, probably just plain VC++6.0.
Ive ordered a copy of the Feb 2003 version on CD. Can it be downloaded from anywhere?
thanks,
Rainos
|
|
|
|
|
I plugged your IsUserAdmin() funnction into one of my dialog-based applications and it compiled/linked without issue.
Rainos wrote:
Can it be downloaded from anywhere?
Not any more. It was downloadable up until a few months ago.
Good luck.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Thanks for trying that.
Im guessing you have Platform SDK installed then?
If so that confirms that I need it.
thanks,
Rainos
|
|
|
|
|
Rainos wrote:
Im guessing you have Platform SDK installed then?
That is correct.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi All,
I've been working on a project that makes use of CTabCtrl in a derived class.
My problem is that when my application runs on Windows XP Themed, the background color of that tabs that should be white (?)- default - are gray as the dialogs that they are. So it causes a strange feeling... the tabs titles are white and beautiful... but the tabs contents are gray...
Does anybody already pass through this or have some idea of how can I avoid this? Maybe makes the color of my dialogs (tab contents) transparent... I just don't know
ps.: its important that works on XP Themed and other versions of Windows too.
Thanks all for the attention,
Cheers!
-- modified at 10:16 Thursday 15th September, 2005
|
|
|
|
|
RickyC wrote:
makes use of CTabCtrl in a derived class.
The default CTabCtrl displays a white background (as expected) on my themed XP system. Perhaps the derived control you're using swaps in modeless dialogs when the user switches tabs? If so, the dialog's background will be COLOR_WINDOW (grey) by default.
Instead of the CTabCtrl derived control, you may want to try using a CPropertySheet (and CPropertyPage s) and see if that gets you the desired behavior.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Hi Ravi, thanks for your answer.
I have been looking into CPropertySheet and the problem that I see, is that CPropertySheet behave like a Modal Dialog isn't?
And my CTabCtrl is inside a Dialog, like part of the controls of that Dialog.
Can I use the CPropertySheet like a normal MFC Control otherwise than a separated Modal Dialog?
Well, I'll try'it anyway
Thank you very much for your patience and assistance.
|
|
|
|
|
Can I use the CPropertySheet like a normal MFC Control
Yes, absolutely! See this[^] article for instructions.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Thanks Ravi!
You help me a lot!
|
|
|
|
|
|
Hi,
If I'm implementing a view that recieves WM_COMMAND messages, and OnUpdateCmdUIs, what is the easiest way to include some of my view's child windows in the routing, so that they can also recieve these notifications, without reflecting each notification one by one?
Joel Holdsworth
|
|
|
|
|
It's a bit hacky but I often override OnCmdMsg() and forward it on to the child windows to see if any of them want it.
The two most common elements in the universe are Hydrogen and stupidity. - Harlan Ellison
Awasu 2.1.2 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Thanks a lot. Worked like a charm!
Joel Holdsworth
|
|
|
|
|
Hi
I'm writing an application and I would like to add a search function to it. What I would like to have is something similar to the "search file" function from the explorer, but using my own search search parameters and search engine. And this is where I get confused
Browsing the msdn I found two things :
-> Search Handler. I found a little description of what they are in the "Creating Search Handlers"(1) document, but that didn't help me much. What are they really capable of ? Are they the solution to my problem (custom search engine based on custom parameters) or are they just a tool to help XP search in file ? (I mean, like described here )
-> Explorer pane. I was able to implement a vertical explorer pane and adding a few event to it (straight win32 message loop, nothing fancy), but how can I display the search result the same way they are displayed when searching for file ? (To clear a bit this : I receive the "search" event. My app looks input values and perform the search. How can I present the results in the right pane (the listview) of the explorer ?)
Thanks !
-----------------------------
(1) Creating Search Handlers
|
|
|
|
|
I have an MFC MDI application in VC++ which is active document server application which allows opening document in container like internet explorer.
Is it possible to create the active document server application using .NET framework and allow to open document in internet explorer?
Any tips on the same will be helpful.
Thanks.
|
|
|
|
|
HI, can anybody tell me how get File Version without using GetFileVersionInfoSize() do let me know.
Thanks in advance.
Regards,
Supriya Tonape
|
|
|
|
|
|
ThatsAlok wrote:
I Believe, you are facing trouble using GetFileVersionInfoSize...
Why would there be trouble in using GetFileVersionInfoSize() ? Aside from reading the EXE/DLL directly, that function, along with VerQueryValue() , are the only way to go.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
thanks to both of U dear but I m not able to get desired o/p
below is sample code I m doing, I m getting Invalid data Error (13)
====================
DWORD dwVerInfoSize; // Size of version information block
DWORD dwVerHnd = 0; // An 'ignored' parameter, always '0'
TCHAR *szAppName= L"C:\\Documents and Settings\\Desktop\\unicows.exe";
TCHAR *verdata = L"";
//WIN32_FIND_DATA var;
//HANDLE hFileHandle = FindFirstFile (szAppName,&var);
dwVerInfoSize = GetFileVersionInfoSize( szAppName, &dwVerHnd );
cout << dwVerInfoSize; // here I m getting o/p as "2052"
GetFileVersionInfo(szAppName,0,dwVerInfoSize,verdata);
LPVOID lpInfo;
UINT unInfoLen;
VerQueryValue(verdata, _T("\\"), &lpInfo, &unInfoLen);
cout<< "lpInfo : " << lpInfo<<"\n\n"; //o/p is 0xccccccc
cout<< "unInfoLen :" << unInfoLen; // o/p is zero
cout<<"\n"<< GetLastError(); //13
========================
tell me what's wrong in it...
thanks n Regards
Supriya Tonape
-- modified at 6:27 Friday 16th September, 2005
|
|
|
|
|
Supriya Tonape wrote:
GetFileVersionInfo(szAppName,0,dwVerInfoSize,verdata);
Here verdata does not point to a valid block of memory. See here for code snippets that use these functions.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|