Click here to Skip to main content
15,890,185 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
Questionprinter driver Pin
dufduf7-Oct-11 20:11
dufduf7-Oct-11 20:11 
AnswerRe: printer driver Pin
Luc Pattyn8-Oct-11 3:48
sitebuilderLuc Pattyn8-Oct-11 3:48 
Question[Need Help] some thing about output Pin
Mike@Shanghai3-Oct-11 22:58
Mike@Shanghai3-Oct-11 22:58 
AnswerRe: [Need Help] some thing about output Pin
Mike@Shanghai3-Oct-11 23:04
Mike@Shanghai3-Oct-11 23:04 
AnswerRe: [Need Help] some thing about output Pin
Mike@Shanghai3-Oct-11 23:49
Mike@Shanghai3-Oct-11 23:49 
GeneralRe: [Need Help] some thing about output Pin
Richard MacCutchan4-Oct-11 1:28
mveRichard MacCutchan4-Oct-11 1:28 
GeneralRe: [Need Help] some thing about output Pin
Mike@Shanghai4-Oct-11 2:05
Mike@Shanghai4-Oct-11 2:05 
QuestionHow can program tell that itself is running as admin? Pin
Brandon-X120001-Oct-11 5:40
Brandon-X120001-Oct-11 5:40 
Hello people I have the following the code written in C++, converted from Vb.net to C++ from a program, the following code tells the user via message box if the program is running as an admin, see below


C++
Object ^identity = WindowsIdentity::GetCurrent();
WindowsPrincipal ^principal = gcnew WindowsPrincipal(identity);
bool isElevated = principal->IsInRole(WindowsBuiltInRole::Administrator);

try
    {
    if (isElevated == true)
    {
    }
    else
    {
        MessageBox::Show("WARNING: Program not running as administrator!", "Credential Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
    }
    }
catch (Exception ^ex)
{
    MessageBox::Show("This program cannot run as performed because your system does not support admin rights, program now terminating from computer memory.", ".Net Framework Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
    Environment::Exit(1);
}


When this block of code was executed with my program, I get the following error message (In double quotations):

"error C2664: 'System::Security::Principal::WindowsPrincipal::WindowsPrincipal(System::Security::Principal::WindowsIdentity ^)' : cannot convert parameter 1 from 'System::Object ^' to 'System::Security::Principal::WindowsIdentity ^'"

the remaining error messages are (In double quotations):

"1> No user-defined-conversion operator available, or
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast"


Could anyone point out something that I could edit that could make the compiler accept or work, any suggestions or personal solutions are appreciated Smile | :) .
AnswerRe: How can program tell that itself is running as admin? Pin
Luc Pattyn1-Oct-11 5:58
sitebuilderLuc Pattyn1-Oct-11 5:58 
GeneralRe: How can program tell that itself is running as admin? Pin
Brandon-X120001-Oct-11 6:13
Brandon-X120001-Oct-11 6:13 
AnswerRe: How can program tell that itself is running as admin? Pin
Luc Pattyn1-Oct-11 6:31
sitebuilderLuc Pattyn1-Oct-11 6:31 
AnswerRe: How can program tell that itself is running as admin? Pin
Richard MacCutchan1-Oct-11 6:02
mveRichard MacCutchan1-Oct-11 6:02 
GeneralRe: How can program tell that itself is running as admin? Pin
Brandon-X120001-Oct-11 6:13
Brandon-X120001-Oct-11 6:13 
GeneralRe: How can program tell that itself is running as admin? Pin
Richard MacCutchan1-Oct-11 6:36
mveRichard MacCutchan1-Oct-11 6:36 
GeneralHandle Leak when Compiling with /clr Option, and _beginthread. Pin
Mike Doner29-Sep-11 6:49
Mike Doner29-Sep-11 6:49 
QuestionShow text after press a button Pin
antonio34327-Sep-11 8:27
antonio34327-Sep-11 8:27 
AnswerRe: Show text after press a button Pin
Albert Holguin29-Sep-11 10:59
professionalAlbert Holguin29-Sep-11 10:59 
Questioncreatefile() API fail for mapped/shared network drives Pin
s v joshi25-Sep-11 23:28
s v joshi25-Sep-11 23:28 
Questioncreate wrapper class in vc ++ Pin
vitthal0902197722-Sep-11 4:31
vitthal0902197722-Sep-11 4:31 
QuestionDifference between a User dump and Kernel dump Pin
rupeshkp72822-Sep-11 0:17
rupeshkp72822-Sep-11 0:17 
AnswerRe: Difference between a User dump and Kernel dump Pin
Richard MacCutchan22-Sep-11 2:52
mveRichard MacCutchan22-Sep-11 2:52 
Questionora-12541 in c++/cli project.. Pin
aupres12-Sep-11 19:02
aupres12-Sep-11 19:02 
Questionproblem communicating between managed and unmanaged code inside a dll Pin
mtestt8-Sep-11 5:32
mtestt8-Sep-11 5:32 
AnswerRe: problem communicating between managed and unmanaged code inside a dll Pin
Richard Andrew x649-Sep-11 13:56
professionalRichard Andrew x649-Sep-11 13:56 
Questionhooking winsock send function Pin
vkgktm24-Aug-11 1:31
vkgktm24-Aug-11 1:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.