Click here to Skip to main content
15,909,325 members
Home / Discussions / COM
   

COM

 
QuestionCreateInstance failed in Windows service Pin
hybride25-Oct-06 19:32
hybride25-Oct-06 19:32 
AnswerRe: CreateInstance failed in Windows service Pin
Jonathan [Darka]26-Oct-06 4:25
professionalJonathan [Darka]26-Oct-06 4:25 
GeneralRe: CreateInstance failed in Windows service Pin
hybride27-Oct-06 1:08
hybride27-Oct-06 1:08 
GeneralRe: CreateInstance failed in Windows service Pin
Jonathan [Darka]27-Oct-06 3:24
professionalJonathan [Darka]27-Oct-06 3:24 
AnswerRe: CreateInstance failed in Windows service Pin
hybride29-Oct-06 20:26
hybride29-Oct-06 20:26 
GeneralRe: CreateInstance failed in Windows service Pin
Jonathan [Darka]29-Oct-06 21:39
professionalJonathan [Darka]29-Oct-06 21:39 
AnswerRe: CreateInstance failed in Windows service Pin
hybride29-Oct-06 21:50
hybride29-Oct-06 21:50 
GeneralRe: CreateInstance failed in Windows service Pin
Jonathan [Darka]30-Oct-06 3:24
professionalJonathan [Darka]30-Oct-06 3:24 
Try something like this:

<code>TCHAR szDomain[] = 'DomainName'; // Change this to the domain that the user belongs to
TCHAR szUserName[] = 'Username'; // Change this to the desired user name
TCHAR szPassword[] = 'Password'; // Change this to th e user's pasword

HANDLE hUser = NULL;

BOOL bLoggedOn = LogonUser(szUserName, szDomain, szPassword, LOGON32_LOGON_NEW_CREDENTIALS, LOGON32_PROVIDER_WINNT50, &hUser);
if(!bLoggedOn) // Did it work ?
{
	DWORD dwErr = GetLastError(); // Process Error Here
	return;
}

	// Logon worked, so impersonate
if(!ImpersonateLoggedOnUser(hUser))
{
	DWORD dwErr = GetLastError(); // Process Error Here
	return;
}

	// Now you can call CreateInstanceHere

CoInitialize(0);

SHDocVw::IShellWindowsPtr spSHWinds;
HRESULT hr = spSHWinds.CreateInstance (__uuidof(SHDocVw::ShellWindows));

	// .. Do your work here
	// ...
	// ...
	// ...
	// ...
	// .. Make sure you are finished with spSHWinds before you call RevertToSelf();

	// Once done, you need to revery back to the LOCAL SYSTEM account
RevertToSelf();




Darka [Xanya]

"I am not a slave to a god that doesn't exist."

GeneralRe: CreateInstance failed in Windows service Pin
hybride30-Oct-06 23:49
hybride30-Oct-06 23:49 
QuestionHow to mashal IElementBehaviorFactory interface? Pin
jinhaibo25-Oct-06 16:55
jinhaibo25-Oct-06 16:55 
AnswerRe: How to mashal IElementBehaviorFactory interface? Pin
Stephen Hewitt25-Oct-06 18:47
Stephen Hewitt25-Oct-06 18:47 
GeneralRe: How to mashal IElementBehaviorFactory interface? Pin
jinhaibo25-Oct-06 19:37
jinhaibo25-Oct-06 19:37 
GeneralRe: How to mashal IElementBehaviorFactory interface? Pin
Stephen Hewitt25-Oct-06 19:44
Stephen Hewitt25-Oct-06 19:44 
GeneralRe: How to mashal IElementBehaviorFactory interface? Pin
jinhaibo25-Oct-06 20:03
jinhaibo25-Oct-06 20:03 
QuestionHow to debug when I'm developing an outlook add-in using COM? Pin
OctopusThu25-Oct-06 8:35
OctopusThu25-Oct-06 8:35 
AnswerRe: How to debug when I'm developing an outlook add-in using COM? Pin
Jörgen Sigvardsson25-Oct-06 9:48
Jörgen Sigvardsson25-Oct-06 9:48 
GeneralRe: How to debug when I'm developing an outlook add-in using COM? Pin
Mike Dimmick25-Oct-06 23:54
Mike Dimmick25-Oct-06 23:54 
QuestionNeed to read value from config file Pin
Shilpa124-Oct-06 10:24
Shilpa124-Oct-06 10:24 
AnswerRe: Need to read value from config file Pin
voorugonda prashanth29-Oct-06 23:09
voorugonda prashanth29-Oct-06 23:09 
Questiongetactiveobject vs cocreateinstance Pin
sbuchner24-Oct-06 2:43
sbuchner24-Oct-06 2:43 
QuestionC# & mswinsock.ocx Pin
Shahin7719-Oct-06 11:41
Shahin7719-Oct-06 11:41 
AnswerRe: C# & mswinsock.ocx Pin
Mike Dimmick23-Oct-06 1:43
Mike Dimmick23-Oct-06 1:43 
QuestionActivedocument error - word addin problem Pin
K edar V18-Oct-06 20:07
K edar V18-Oct-06 20:07 
AnswerRe: Activedocument error - word addin problem Pin
K edar V18-Oct-06 20:25
K edar V18-Oct-06 20:25 
QuestionError while Installing Pin
Jeeva Mary Varghese18-Oct-06 19:26
Jeeva Mary Varghese18-Oct-06 19:26 

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.