Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
2.3 KiB

  1. /*
  2. *
  3. * bin files:
  4. * copy \\termsrv\smclient\last\x86\*
  5. * For whistler client:
  6. * copy smclient.ini.clshell smclient.ini
  7. * --- SOURCES
  8. * INCLUDES=$(TERMSRV_TST_ROOT)\inc;
  9. * UMLIBS=$(TERMSRV_TST_ROOT)\lib\$(O)\tclient.lib
  10. * ---
  11. */
  12. #include <protocol.h>
  13. #include <extraexp.h>
  14. //
  15. // This sample code connects and then logs off a TS client
  16. //
  17. BOOL
  18. TS_Logon_Logoff(
  19. LPCSTR szServer,
  20. LPCSTR szUsername,
  21. LPCSTR szDomain
  22. )
  23. {
  24. BOOL rv = FALSE;
  25. PVOID pCI;
  26. LPCSTR rc;
  27. //
  28. // Use SCConnect for UNICODE params
  29. //
  30. rc = SCConnectA(szServer,
  31. szUsername,
  32. szPassword,
  33. szDomain,
  34. 0, // Resol X, default is 640
  35. 0, // Resol Y, default is 480
  36. &pCI); // context record
  37. //
  38. // rc is NULL and pCI non-NULL on success
  39. //
  40. if (rc || !pCI)
  41. goto exitpt;
  42. //
  43. // Wait for the desktop to appear
  44. //
  45. rc = SCCheckA(pCI, "Wait4Str", "MyComputer" );
  46. if ( rc )
  47. goto exitpt;
  48. SCLogoff( pCI );
  49. pCI = NULL;
  50. rv = TRUE;
  51. exitpt:
  52. if ( pCI )
  53. SCDisconnect( pCI );
  54. return rv;
  55. }
  56. //
  57. // Print debug output from tclient.dll
  58. //
  59. VOID
  60. _cdecl
  61. _PrintMessage(MESSAGETYPE errlevel, LPCSTR format, ...)
  62. {
  63. CHAR szBuffer[256];
  64. CHAR *type;
  65. va_list arglist;
  66. INT nchr;
  67. if (g_bVerbose < 2 &&
  68. errlevel == ALIVE_MESSAGE)
  69. goto exitpt;
  70. if (g_bVerbose < 1 &&
  71. errlevel == INFO_MESSAGE)
  72. goto exitpt;
  73. va_start (arglist, format);
  74. nchr = _vsnprintf (szBuffer, sizeof(szBuffer), format, arglist);
  75. va_end (arglist);
  76. szBuff[ sizeof(szBuffer) - 1 ] = 0;
  77. switch(errlevel)
  78. {
  79. case INFO_MESSAGE: type = "INF"; break;
  80. case ALIVE_MESSAGE: type = "ALV"; break;
  81. case WARNING_MESSAGE: type = "WRN"; break;
  82. case ERROR_MESSAGE: type = "ERR"; break;
  83. default: type = "UNKNOWN";
  84. }
  85. printf("%s:%s", type, szBuffer);
  86. exitpt:
  87. ;
  88. }
  89. void
  90. main( void )
  91. {
  92. //
  93. // Init tclient.dll
  94. //
  95. SCINITDATA scinit;
  96. scinit.pfnPrintMessage = _PrintMessage;
  97. SCInit(&scinit);
  98. TS_Logon_Logoff( "TERMSRV", "smc_user", "Vladimis98" );
  99. }