473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How do I call WTSOpenServer in VC++?

This is my first attempt at using the Terminal Services API, and I'm
stumped. I can't get WTSOpenServer to work for the life of me (this is
in VS2005, by the way). Specifically, the argument has me baffled.
It's my understanding that it wants a LPWSTR (at least on this machine,
where UNICODE is defined). My first attempt was:

HANDLE hnd = WTSOpenServer("asdf");

Which yielded:
error C2664: 'WTSOpenServerW' : cannot convert parameter 1 from 'const
char [5]' to 'LPWSTR'

Fine. So I tried:

HANDLE hnd = WTSOpenServer(A2T("asdf"));

Which pukes up:
error LNK2028: unresolved token (0A000415) "extern "C" void * __stdcall
WTSOpenServerW(wchar_t *)" (?WTSOpenServerW@@$$J14YGPAXPA_W@Z)
referenced in function "private: void __clrcall
test::Form1::Form1_Load(class System::Object ^,class System::EventArgs
^)"
(?Form1_Load@Form1@test@@$$FA$AAMXP$AAVObject@Syst em@@P$AAVEventArgs@4@@Z)
test.obj

error LNK2019: unresolved external symbol "extern "C" void * __stdcall
WTSOpenServerW(wchar_t *)" (?WTSOpenServerW@@$$J14YGPAXPA_W@Z)
referenced in function "private: void __clrcall
test::Form1::Form1_Load(class System::Object ^,class System::EventArgs
^)"
(?Form1_Load@Form1@test@@$$FA$AAMXP$AAVObject@Syst em@@P$AAVEventArgs@4@@Z)
test.obj

HANDLE hnd = WTSOpenServer(A2W("asdf")); gave the same results.

Can anyone tell me what on earth I'm doing wrong? I've been googling
for days, and I'm sure it can't be this difficult. Any help is
appreciated. And if I'm in the wrong group, please accept my
apologies.

Adam

Dec 7 '06 #1
3 3547
"Adam" <ad**********@gmail.comwrote in message
news:11*********************@j72g2000cwa.googlegro ups.com...
This is my first attempt at using the Terminal Services API, and I'm
stumped. I can't get WTSOpenServer to work for the life of me (this is
in VS2005, by the way). Specifically, the argument has me baffled.
It's my understanding that it wants a LPWSTR (at least on this machine,
where UNICODE is defined). My first attempt was:

HANDLE hnd = WTSOpenServer("asdf");

Which yielded:
error C2664: 'WTSOpenServerW' : cannot convert parameter 1 from 'const
char [5]' to 'LPWSTR'

Fine. So I tried:

HANDLE hnd = WTSOpenServer(A2T("asdf"));

Which pukes up:
error LNK2028: unresolved token (0A000415) "extern "C" void * __stdcall
WTSOpenServerW(wchar_t *)" (?WTSOpenServerW@@$$J14YGPAXPA_W@Z)
referenced in function "private: void __clrcall
test::Form1::Form1_Load(class System::Object ^,class System::EventArgs
^)"
(?Form1_Load@Form1@test@@$$FA$AAMXP$AAVObject@Syst em@@P$AAVEventArgs@4@@Z)
test.obj

error LNK2019: unresolved external symbol "extern "C" void * __stdcall
WTSOpenServerW(wchar_t *)" (?WTSOpenServerW@@$$J14YGPAXPA_W@Z)
referenced in function "private: void __clrcall
test::Form1::Form1_Load(class System::Object ^,class System::EventArgs
^)"
(?Form1_Load@Form1@test@@$$FA$AAMXP$AAVObject@Syst em@@P$AAVEventArgs@4@@Z)
test.obj

HANDLE hnd = WTSOpenServer(A2W("asdf")); gave the same results.

Can anyone tell me what on earth I'm doing wrong? I've been googling
for days, and I'm sure it can't be this difficult. Any help is
appreciated. And if I'm in the wrong group, please accept my
apologies.

Adam

..... WTSOpenServer(L"asdf");

Willy.

Dec 8 '06 #2
Can anyone tell me what on earth I'm doing wrong? I've been googling
for days, and I'm sure it can't be this difficult. Any help is
appreciated. And if I'm in the wrong group, please accept my
apologies.
As Willy says, you can directly use L"string" to get a unicode string
literal, no point in converting from ANSI at runtime.

But your linker error will only be resolved when you add WtsApi32.lib to
your project properties under "Linker -Inputs".

See the doc page:
http://msdn.microsoft.com/library/de...openserver.asp
The Requirements section clearly shows the header file and import library
needed.
>
Adam

Dec 11 '06 #3
Yes, that was the problem - I had neglected to include the .lib. Thank
you. I feel like an idiot.

Adam

Ben Voigt wrote:
Can anyone tell me what on earth I'm doing wrong? I've been googling
for days, and I'm sure it can't be this difficult. Any help is
appreciated. And if I'm in the wrong group, please accept my
apologies.

As Willy says, you can directly use L"string" to get a unicode string
literal, no point in converting from ANSI at runtime.

But your linker error will only be resolved when you add WtsApi32.lib to
your project properties under "Linker -Inputs".

See the doc page:
http://msdn.microsoft.com/library/de...openserver.asp
The Requirements section clearly shows the header file and import library
needed.

Adam
Dec 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Eugene Safrankow | last post by:
Hello All! I've encountered with the error when I call a method of dependency library (written in managed VC++) from Smart Client placed on a web page. In general, I make a call to the Windows...
8
by: Paul | last post by:
Hi all may I know how to use C# DLL inside my VC++ Project ? Thanks in advance.
6
by: Christopher Attard | last post by:
Hi, I'm using WTSOpenServer (P/Invoke in a C# application) to open a handle to a specified terminal server which is Win2003 Server Domain Controller. The function is returning NULL (or 0). I'm...
2
by: Al | last post by:
Could anybody point me to some resource about how to call a VB.net DLL in VC.net? Thanks in advance. Al
1
by: Robert Ludewig | last post by:
I have sucessfully imported and compiled a complex MFC 6.0 project from vc++6.0 (MFC6.0) into vc++ 8.0 (MFC 8.0). It contains several subprojects (libs and dlls). In vc++ 6.0 those project linked...
1
by: Mads Westen | last post by:
Hi, I want to create a "dynamic" unmanaged VC++ wrapper that can call any C# DLL. I'm thinking that I call the the wrapper from another program like this: dllcall(name_of_wrapper_function ,...
0
by: Manu | last post by:
Hi, To get the USERNAME of all process running in local/remote system I am using the WTSOpenServer and WTSEnumerateProcesses API's but when I invoke the WTSOpenServer in Windows 200...
6
by: fiefie.niles | last post by:
We have a C++ DLL that we call from VB6 program. This is how we declare the DLL in VB6: Declare Function RefSearch Lib "csearch32.dll" (ByVal path As String, ByVal findword As String, ByVal...
3
by: Josemi | last post by:
Hi!, I've got a great problem, and I don't have any idea how can I to solve it. I hope that there is a solution to solve it :-). Well. I've got an App UNICODE that call a routine in a dll MBCS:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.