20#include <freerdp/config.h> 
   27#include <winpr/tchar.h> 
   28#include <winpr/windows.h> 
   30#include "wf_interface.h" 
   34#include <freerdp/server/server-common.h> 
   35#include <freerdp/log.h> 
   36#define TAG SERVER_TAG("windows") 
   40BOOL CALLBACK moncb(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
 
   42  WLog_DBG(TAG, 
"%d\t(%ld, %ld), (%ld, %ld)", IDcount, lprcMonitor->left, lprcMonitor->top,
 
   43           lprcMonitor->right, lprcMonitor->bottom);
 
   48int main(
int argc, 
char* argv[])
 
   50  freerdp_server_warn_unmaintained(argc, argv);
 
   52  BOOL screen_selected = FALSE;
 
   55  server = wfreerdp_server_new();
 
   63    if (strcmp(
"--list-screens", argv[index]) == 0)
 
   68      WLog_INFO(TAG, 
"Detecting screens...");
 
   69      WLog_INFO(TAG, 
"ID\tResolution\t\tName (Interface)");
 
   73        _TCHAR name[128] = { 0 };
 
   74        if (get_screen_info(i, name, ARRAYSIZE(name), &width, &height, &bpp) != 0)
 
   76          if ((width * height * bpp) == 0)
 
   79          WLog_INFO(TAG, 
"%d\t%dx%dx%d\t", i, width, height, bpp);
 
   80          WLog_INFO(TAG, 
"%s", name);
 
   91        vscreen_w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
 
   92        vscreen_h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
 
   94        EnumDisplayMonitors(NULL, NULL, moncb, 0);
 
   96        WLog_INFO(TAG, 
"Virtual Screen = %dx%d", vscreen_w, vscreen_h);
 
  102    if (strcmp(
"--screen", argv[index]) == 0)
 
  105      screen_selected = TRUE;
 
  110        WLog_INFO(TAG, 
"missing screen id parameter");
 
  114      val = strtoul(argv[index], NULL, 0);
 
  116      if ((errno != 0) || (val > UINT32_MAX))
 
  123    if (index == argc - 1)
 
  125      UINT32 val = strtoul(argv[index], NULL, 0);
 
  127      if ((errno != 0) || (val > UINT32_MAX))
 
  135  if (screen_selected == FALSE)
 
  140    WLog_INFO(TAG, 
"screen id not provided. attempting to detect...");
 
  141    WLog_INFO(TAG, 
"Detecting screens...");
 
  142    WLog_INFO(TAG, 
"ID\tResolution\t\tName (Interface)");
 
  144    for (
int i = 0;; i++)
 
  146      _TCHAR name[128] = { 0 };
 
  147      if (get_screen_info(i, name, ARRAYSIZE(name), &width, &height, &bpp) != 0)
 
  149        if ((width * height * bpp) == 0)
 
  152        WLog_INFO(TAG, 
"%d\t%dx%dx%d\t", i, width, height, bpp);
 
  153        WLog_INFO(TAG, 
"%s", name);
 
  164  WLog_INFO(TAG, 
"Starting server");
 
  165  wfreerdp_server_start(server);
 
  166  (void)WaitForSingleObject(server->thread, INFINITE);
 
  167  WLog_INFO(TAG, 
"Stopping server");
 
  168  wfreerdp_server_stop(server);
 
  169  wfreerdp_server_free(server);