Click here to Skip to main content
16,016,164 members
Home / Discussions / C#
   

C#

 
QuestionEnable custom control to be editable or intreactive in Design Mode Pin
leeoze26-May-08 3:46
leeoze26-May-08 3:46 
AnswerRe: Enable custom control to be editable or intreactive in Design Mode Pin
leppie26-May-08 4:08
leppie26-May-08 4:08 
GeneralRe: Enable custom control to be editable or intreactive in Design Mode Pin
Brady Kelly26-May-08 10:54
Brady Kelly26-May-08 10:54 
GeneralRe: Enable custom control to be editable or intreactive in Design Mode Pin
leppie26-May-08 12:12
leppie26-May-08 12:12 
GeneralRe: Enable custom control to be editable or intreactive in Design Mode Pin
Brady Kelly26-May-08 13:13
Brady Kelly26-May-08 13:13 
GeneralRe: Enable custom control to be editable or intreactive in Design Mode Pin
leppie26-May-08 23:33
leppie26-May-08 23:33 
GeneralRe: Enable custom control to be editable or intreactive in Design Mode Pin
Brady Kelly26-May-08 23:36
Brady Kelly26-May-08 23:36 
QuestionService launching app with admin rights not working other than session 0 (XP) - C# Pin
xtnerb26-May-08 3:35
xtnerb26-May-08 3:35 
Hi guyz!.. i'm trying to launch an application from a service with an elevated right. THe application actually needs admin rights to lock folders and read processes on the system. The code i tried to compose works when the active session is 0 but when I lock the account under session 0 and login into another session, it launches the application on the previous account, seeing the launch program after going back to the previous account. How can i Solve this problem?.
Here is my function using createprocessasuser()
******************************************************
IntPtr l_ptrBuffer = IntPtr.Zero;

int errorCode = 0;
bool ret;
IntPtr token = new IntPtr(0);
IntPtr dupedToken = new IntPtr(0);
UInt32 dwSessionID;


SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES();
sa.bInheritHandle = false;
sa.Length = Marshal.SizeOf(sa);
sa.lpSecurityDescriptor = (IntPtr)0;


PROCESS_INFORMATION pi = new PROCESS_INFORMATION();

STARTUPINFO si = new STARTUPINFO();
si.cb = Marshal.SizeOf(si);
si.lpDesktop = "winsta0\\default";
si.dwFlags = STARTF.STARTF_USESHOWWINDOW;
si.wShowWindow = ShowWindow.SW_SHOW;

this.writetolog("token b4:" + token);
dwSessionID = WTSGetActiveConsoleSessionId();
this.writetolog("from exe: " + dwSessionID.ToString());

WTS_INFO_CLASS.WTSUserName, out l_ptrBuffer, out l_nBytes);

if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_DUPLICATE | TOKEN_ASSIGN_PRIMARY | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_SESSIONID, out token))
{
this.writetolog("dili successful pag openprocesstoken");
}

this.writetolog("token mid:" + token + "current process: " + GetCurrentProcess());
const uint GENERIC_ALL = 0x10000000;

const int SecurityImpersonation = 2;
const int TokenType = 1;

ret = DuplicateTokenEx(token, GENERIC_ALL, ref sa, SecurityImpersonation, TokenType, out dupedToken);

if (ret == false)
{
this.writetolog("dili successful pag duplic8");
}
this.writetolog("duptoken b4:" + dupedToken);

SetTokenInformation(dupedToken, TOKEN_INFORMATION_CLASS.TokenSessionId, dwSessionID, (uint)IntPtr.Size);

CloseHandle(token);

ImpersonateLoggedOnUser(dupedToken);


ret = CreateProcessAsUser(dupedToken,
executable,
cmdLine,
ref sa,
ref sa,
false,
0,
(IntPtr)0,
null,
ref si,
out pi);

if (ret == false)
{


this.writetolog("ala ka create og process");
}

if (WaitForSingleObject(pi.hProcess, timeOut) != 0)
{

}
uint ec;
GetExitCodeProcess(pi.hProcess, out ec);
errorCode = (int)ec;

RevertToSelf();
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);

CloseHandle(dupedToken);

return errorCode;
******************************************************


Please help me guyz. Thankz Frown | :(
AnswerTO add up on the information Pin
xtnerb26-May-08 15:35
xtnerb26-May-08 15:35 
QuestionOpen a new e-mail with attachment in the default e-mail program. Pin
Christian Wikander26-May-08 2:02
Christian Wikander26-May-08 2:02 
AnswerRe: Open a new e-mail with attachment in the default e-mail program. Pin
jzonthemtn26-May-08 10:04
jzonthemtn26-May-08 10:04 
GeneralRe: Open a new e-mail with attachment in the default e-mail program. Pin
Christian Wikander26-May-08 20:38
Christian Wikander26-May-08 20:38 
QuestionThe .Net framework does not like my thread [modified] Pin
CDP180226-May-08 1:57
CDP180226-May-08 1:57 
AnswerRe: The .Net framework does not like my thread Pin
leppie26-May-08 3:50
leppie26-May-08 3:50 
GeneralRe: The .Net framework does not like my thread Pin
CDP180226-May-08 4:06
CDP180226-May-08 4:06 
GeneralRe: The .Net framework does not like my thread Pin
leppie26-May-08 4:13
leppie26-May-08 4:13 
GeneralRe: The .Net framework does not like my thread Pin
CDP180226-May-08 22:03
CDP180226-May-08 22:03 
GeneralRe: The .Net framework does not like my thread Pin
mav.northwind27-May-08 3:48
mav.northwind27-May-08 3:48 
GeneralRe: The .Net framework does not like my thread Pin
CDP180227-May-08 4:09
CDP180227-May-08 4:09 
GeneralRe: The .Net framework does not like my thread Pin
mav.northwind27-May-08 8:26
mav.northwind27-May-08 8:26 
GeneralRe: The .Net framework does not like my thread [modified] Pin
CDP180227-May-08 22:19
CDP180227-May-08 22:19 
GeneralRe: The .Net framework does not like my thread Pin
mav.northwind27-May-08 23:24
mav.northwind27-May-08 23:24 
QuestionIs it possible to query any text on xmldata of sqlserver 2005 table? Pin
nicolus26-May-08 1:47
nicolus26-May-08 1:47 
AnswerRe: Is it possible to query any text on xmldata of sqlserver 2005 table? Pin
buchstaben26-May-08 3:19
buchstaben26-May-08 3:19 
GeneralRe: Is it possible to query any text on xmldata of sqlserver 2005 table? Pin
nicolus26-May-08 20:57
nicolus26-May-08 20:57 

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.