master
md 49 lines 1.88 KB
Rendered Raw
1 # SessionSettings
2
3 **Constructor**
4
5 - `SessionSettings(hstring name, hstring storagePath)`
6 - `name` must be non-empty. The name of the session to be created.
7 - `storagePath` must be non-empty. Path to where the session storage should be written. If the path doesn't exist, it will be created.
8
9 Session names serve both as display names and as machine-wide keys used to identify sessions. If a session with the same name already exists, session creation will fail with `ERROR_ALREADY_EXISTS`.
10
11 Also note that the following information about a session is visible to all users on the machine:
12
13 - The session's name
14 - The SID of the user that created the session
15 - The PID of the process that created the session
16
17 Do not put credentials or other sensitive information in the session's name.
18
19 **Properties**
20
21 - `Name()` / setter
22 - `StoragePath()` / setter
23 - `CpuCount()` / setter (`0` rejected)
24 - `MemorySizeInMB()` / setter (`0` rejected)
25 - `Timeout()` / setter
26 - cannot be zero
27 - cannot be negative
28 - converted to **milliseconds** and must fit in `uint32_t`
29 - `VhdRequirements()` / setter
30 - setter rejects `nullptr`
31 - `EnableGpu()` / setter
32
33 ```cpp
34 SessionSettings settings{ L"demo", L"C:\\WSLC\\demo" };
35 settings.Name(L"demo");
36 settings.StoragePath(L"C:\\WSLC\\demo");
37 settings.CpuCount(winrt::box_value<uint32_t>(4).as<winrt::Windows::Foundation::IReference<uint32_t>>());
38 settings.MemorySizeInMB(winrt::box_value<uint32_t>(4096).as<winrt::Windows::Foundation::IReference<uint32_t>>());
39 settings.Timeout(winrt::box_value(winrt::Windows::Foundation::TimeSpan{ std::chrono::minutes(5) })
40 .as<winrt::Windows::Foundation::IReference<winrt::Windows::Foundation::TimeSpan>>());
41 settings.EnableGpu(true);
42
43 auto name = settings.Name();
44 auto path = settings.StoragePath();
45 auto cpu = settings.CpuCount();
46 auto memory = settings.MemorySizeInMB();
47 auto timeout = settings.Timeout();
48 auto enableGpu = settings.EnableGpu();
49 ```