Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP! CreateProcessWithLogonW() HELP! 2

Status
Not open for further replies.

adiMasher

Programmer
Aug 31, 2001
144
US
To anyone who has ever programmed with the advapi32 library and has ever run across this command I'm sure you know what I'm talking about. Well I hope so at least.

My problem, is that microsoft forgot to include the definition for CreateProcessWithLogonW() in WINBASE.H and I had to create my own header to take care of it. Now however, I am getting the error that __imp__CreateProcessWithLogonW@44 object isn't found. I'm at a loss on what to do.

Does anyone know what the problem is or a good way to work around it?
And I've already tried CreateProcessAsUser which it's problem needs SeTcbPrivelege set and that is not an option.

Thanks for any help.
Martin Asher
ADI Computer Solutions
masher@adi-cs.com
 
the error you're talking about is at link time, right? Have you included the library in the project (i think you did...)?
You may also see that the W at the end of the function name stands for Wide (characters) and is intended for use with wide params.

You could be compiling the project on an A(nsii) option only instead of W(ide).

Usually, in the Windows headers it appears something like this:
Code:
#ifdef UNICODE
#define CreateProcessWithLogon CreateProcessWithLogonW
#else
#define CreateProcessWithLogon CreateProcessWithLogonA

You really should lose the W at the end of the function name and use the compiler options to generate the kind of code you want (Ansii or Wide)

Hope this helps...
[red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
 
add advapi32.lib in linker settings(menu project->settings->link->Object/Library modules) Ion Filipski
1c.bmp


filipski@excite.com
 
Alright, How can I force the compile options one way or the other? Because now it seems to have a problem converting the first parameter from char[14] to cons unsigned short *.
And it's trying this with CreatProcessWithLogonA. Somehow I don't think That it really exists?

Martin
 
Just define _UNICODE in Project-> C/C++ ->Preprocessor for Unicode apps or OLE2ANSI for Ansi.
But again, have you tried to use the function without the W at its end?

And, anyway, somehow i think that REALLY exists... Maybe if you parse the VC headers you are going to find it out... [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
 
__imp__CreateProcessWithLogonW@44 object isn't found....
is a linker error. The compiller will show errors only when sintactically is not correct.
About unicode, not #define _UNICODE but #define UNICODE is correct. If you're using unicode use wchar_t instead of char or BSTR/wchar_t* instead of char*. If compiller show
can't convert from cont char..... to char*, just copy/paste the type from the error and put it in a case like (const char....)yourVariable, so with wchar_t types. Ion Filipski
1c.bmp


filipski@excite.com
 
Alright this is all helping but still I haven't got it to completely work yet.

To answer some of the questions. Yes I have dropped the W and now the header file I made handles it. No problems there. The type casting seems to be doing the program some good by eliminating the warnings that it cant convert char[] to unsigned short. I have also checked and advapi32.lib is added to the linker.

so I can get it to compile but when it goes to link I get that same problem with the __imp__createprocesswithlogonw@44

So take a look and see if you notice anything horribly wrong. I made my own header file with just this in it

WINADVAPI
BOOL
WINAPI
CreateProcessWithLogonA(
LPCWSTR lpUsername,
LPCWSTR lpDomain,
LPCWSTR lpPassword,
DWORD dwLogonFlags,
LPCWSTR lpApplicationName,
LPWSTR lpCommandLine,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCWSTR lpCurrentDirectory,
LPSTARTUPINFOW lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInfo
);

WINADVAPI
BOOL
WINAPI
CreateProcessWithLogonW(
LPCWSTR lpUsername,
LPCWSTR lpDomain,
LPCWSTR lpPassword,
DWORD dwLogonFlags,
LPCWSTR lpApplicationName,
LPWSTR lpCommandLine,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCWSTR lpCurrentDirectory,
LPSTARTUPINFOW lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInfo
);


#ifdef UNICODE
#define CreateProcessWithLogon CreateProcessWithLogonA
#else
#define CreateProcessWithLogon CreateProcessWithLogonW
#endif // !UNICODE



I got all that info straight from MSDN.

Am I doing too much or too little?

Thanks,
Martin
 
I repeat, see in VisualC++ menu your linker settings and do it:

add (I mean write in text box by hand, or type from the keyboard) advapi32.lib in linker settings(menu project->settings->link->Object/Library modules) Ion Filipski
1c.bmp


filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top