Jump to content

Terminal Service is Enable or not using C++ or VC++ Code


Recommended Posts

Guest Rasheed
Posted

Hi all,

 

I need to check Terminal Services is Enable or not on a remote

machine. I find one link from this Forum. link is as below :

 

http://www.pcreview.co.uk/forums/thread-1609344.php

 

and i have get the code as below and executed.

 

BOOL Is_Terminal_Services ()

 

{

 

OSVERSIONINFOEX osvi;

 

DWORDLONG dwlConditionMask = 0;

 

// Initialize the OSVERSIONINFOEX structure.

 

ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));

 

osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

 

osvi.wSuiteMask = VER_SUITE_TERMINAL | VER_SUITE_SINGLEUSERTS;

 

// Initialize the condition mask.

 

VER_SET_CONDITION( dwlConditionMask, VER_SUITENAME, VER_OR );

 

// Perform the test.

 

return VerifyVersionInfo(

 

&osvi,

 

VER_SUITENAME,

 

dwlConditionMask);

 

}

 

int _tmain(int argc, _TCHAR* argv[])

 

{

 

bool bflag = Is_Terminal_Services () ;

 

}

 

But even I am unable to analyze. Because if my Terminal service is

stopped then it returns 0 else it returns 1.

 

But my Terminal service is not enable in Control Panel -> Add and

Remove Programs -> Add / Remove Windows Components -> Terminal

Services.

 

So I need the check the above thing(which is Control Panel -> Add and

Remove Programs -> Add / Remove Windows Components -> Terminal

Services. is Enable or Not) whether Terminal Services are enable or

not so what I need to Do. Kindly provide any code snippet will be

great.

  • Replies 3
  • Created
  • Last Reply
Guest Soo Kuan Teo [MSFT]
Posted

Re: Terminal Service is Enable or not using C++ or VC++ Code

 

I'm not quite understand what you mean by 'Terminal Service is Enable'.

Based on your descriptions, it seems you want to find out if Terminal

Services Application Server mode (win2k3 and earlier, In win2k8 its called

Terminal Server role service) is installed?

If that's what you're looking for, you can try TSWMI

Win32_TerminalServiceSetting LicensingType property.

To see if remote desktop is enabled, you can use TSWMI

Win32_TerminalServiceSetting AllowTSConnections properties.

For more info on TSWMI, please visit:

http://msdn.microsoft.com/en-us/library/aa383477(VS.85).aspx

http://blogs.msdn.com/ts/archive/2006/10/03/Terminal-Services-_2800_TS_2900_-Remote-Configuration-Primer-Part-1.aspx

 

 

 

Thanks

Soo Kuan

 

 

--

This posting is provided "AS IS" with no warranties, and confers no rights.

 

"Rasheed" <sk.rasheedfarhan@gmail.com> wrote in message

news:ce192c45-32b9-41b5-bddf-7f1ed12a9b9e@x35g2000hsb.googlegroups.com...

> Hi all,

>

> I need to check Terminal Services is Enable or not on a remote

> machine. I find one link from this Forum. link is as below :

>

> http://www.pcreview.co.uk/forums/thread-1609344.php

>

> and i have get the code as below and executed.

>

> BOOL Is_Terminal_Services ()

>

> {

>

> OSVERSIONINFOEX osvi;

>

> DWORDLONG dwlConditionMask = 0;

>

> // Initialize the OSVERSIONINFOEX structure.

>

> ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));

>

> osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

>

> osvi.wSuiteMask = VER_SUITE_TERMINAL | VER_SUITE_SINGLEUSERTS;

>

> // Initialize the condition mask.

>

> VER_SET_CONDITION( dwlConditionMask, VER_SUITENAME, VER_OR );

>

> // Perform the test.

>

> return VerifyVersionInfo(

>

> &osvi,

>

> VER_SUITENAME,

>

> dwlConditionMask);

>

> }

>

> int _tmain(int argc, _TCHAR* argv[])

>

> {

>

> bool bflag = Is_Terminal_Services () ;

>

> }

>

> But even I am unable to analyze. Because if my Terminal service is

> stopped then it returns 0 else it returns 1.

>

> But my Terminal service is not enable in Control Panel -> Add and

> Remove Programs -> Add / Remove Windows Components -> Terminal

> Services.

>

> So I need the check the above thing(which is Control Panel -> Add and

> Remove Programs -> Add / Remove Windows Components -> Terminal

> Services. is Enable or Not) whether Terminal Services are enable or

> not so what I need to Do. Kindly provide any code snippet will be

> great.

Guest jolteroli
Posted

Re: Terminal Service is Enable or not using C++ or VC++ Code

 

> I need to check Terminal Services is Enable or not on a remote

> machine. I find one link from this Forum. link is as below :

>

> http://www.pcreview.co.uk/forums/thread-1609344.php

>

> and i have get the code as below and executed.

>

> ...

>

> But even I am unable to analyze. Because if my Terminal service is

> stopped then it returns 0 else it returns 1.

 

That is what you are asking for by this code.

> But my Terminal service is not enable in Control Panel -> Add and

> Remove Programs -> Add / Remove Windows Components -> Terminal

> Services.

 

This is because you are asking for RemoteAdminTS OR TerminalServer enabled.

> So I need the check the above thing(which is Control Panel -> Add and

> Remove Programs -> Add / Remove Windows Components -> Terminal

> Services. is Enable or Not) whether Terminal Services are enable or

> not so what I need to Do. Kindly provide any code snippet will be

> great.

 

Just try

 

osvi.wSuiteMask = VER_SUITE_TERMINAL; // To ask for real terminal service enabled (The component thingy)

 

and

 

osvi.wSuiteMask = VER_SUITE_SINGLEUSERTS; // To ask for remote admin enabled

 

See http://search.msdn.microsoft.com/Default.aspx?query=GetVersionEx and there have a look to the bits of the wSuiteMask member of

the struct.

 

-jolt

Guest Rasheed
Posted

Re: Terminal Service is Enable or not using C++ or VC++ Code

 

Thanks alot Friends ..


×
×
  • Create New...