🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #454

Re: using WTSGetActiveConsoleSessionId()

#454
From: Mike Collins
Date: Thu, 17 Apr 2008 15:15
66 lines
3737 bytes
Hay Ed thanks for the pointer, I actually resolved it by dynamically loading 
it, like this:

   typedef DWORD (WINAPI *WTSGETACTIVECONSOLESESSIONID)(VOID);
   WTSGETACTIVECONSOLESESSIONID lpfnWTSGetActiveConsoleSessionId = NULL;
   lpfnWTSGetActiveConsoleSessionId = 
(WTSGETACTIVECONSOLESESSIONID)GetProcAddress(GetModuleHandle("kernel32.dll"), 
"WTSGetActiveConsoleSessionId");

The project that i'm calling it from is a gina and i had to do some playing 
around to get the dll to export the named functions correctly i.e.
extern "C"
{
   #include <winwlx.h>
};

otherwise winlogon would not load it correctly - maybe this is the cause. 
However, I still stuck with the WTSQueryUserToken issue.  Any thoughts?



"Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket> wrote in message 
news:48075419$1@newsgroups.borland.com...
> Go to the compiler's LIB directory and give this command
>
>    tlib /C import32.LIB , import32.LST
>
> The list of exported items provided by import32.lib will be found in the 
> list file.  Pull the list file up in the editor.  Verify that among those 
> items is WTSGetActiveConsoleSessionId and that it is listed as being 
> provided by kernel32.dll, a Windows DLL.
>
> It is possible that an option setting in the IDE could alter the expected 
> public name for WTSGetActiveConsoleSessionId.  Try using tdump on the 
> object file and looking at the exact text for 
> WTSGetActiveConsoleSessionId.  If it has added leading or trailing 
> characters or the case is different then it will not match.  The solution 
> is to restore the IDE options because different naming implies different 
> calling conventions, something which can cause the program to fail.
>
> If the symbol is correct you could try to provide your own import library.
>
> Go to the command line and change to the project directory.
> Give this command:
>    implib -c  kernel32.LIB  c:\windows\system32\kernel32.DLL
> Go back into the IDE and add kernel32.lib to the project file.
>
> .  Ed
>
>> Mike Collins wrote in message
>> news:48074a72@newsgroups.borland.com...
>>
>> Hay guys, hope everyone is well.
>>
>> Can anyone point me in the right direction here.  I'm trying to launch an 
>> application on the active users desktop from a service.
>>
>> I'm looking at a code snippet from MSDN that uses WTSQueryUserToken / 
>> WTSGetActiveConsoleSessionId to determine the active UI session. Problem 
>> is that the compiler keeps telling me that WTSGetActiveConsoleSessionId() 
>> is an  undefined function.  It's declared in winbase.h and i've included 
>> both  windows.h and winbase.h but to no avail.
>>
>> I'm using BCB 6 Enterprise...
>
> 
Technical Details
Message-ID: <480758e5@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <48074a72@newsgroups.borland.com> <48075419$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,61b1edc79d66af39
X-Google-Attributes: gid10cc67,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Mike Collins" <its@TheBottomOfThePost>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <48074a72@newsgroups.borland.com> <48075419$1@newsgroups.borland.com>
Subject: Re: using WTSGetActiveConsoleSessionId()
Date: Thu, 17 Apr 2008 15:15:00 -0000
Lines: 68
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.3959
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 78.144.108.240
Message-ID: <480758e5@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1208441061 78.144.108.240 (17 Apr 2008 07:04:21 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail