@@ -13,9 +13,26 @@ LPTSTR GetErrorMessage();
1313void print (char const * fmt , ...);
1414void InstallService (int ServiceStartType , LPCSTR Path );
1515void RemoveService ();
16+ void CreateBridge ();
17+ extern BOOL IsLinux ;
18+
19+ HWND hwnd = NULL ;
1620
1721VOID HandleStartButton (BOOL Silent )
1822{
23+ if (!IsLinux )
24+ {
25+ ShowWindow (hwnd , SW_MINIMIZE );
26+ CreateThread (NULL , 0 , (LPTHREAD_START_ROUTINE )CreateBridge ,
27+ NULL , 0 , NULL );
28+
29+ HWND item = GetDlgItem (hwnd , /* Start Button */ 1 );
30+ EnableWindow (item , FALSE);
31+ item = GetDlgItem (hwnd , 4 );
32+ SetWindowText (item , "Bridge is running..." );
33+ return ;
34+ }
35+
1936 SC_HANDLE hSCManager = OpenSCManager (NULL , NULL , SC_MANAGER_ALL_ACCESS );
2037 if (hSCManager == NULL )
2138 {
@@ -113,19 +130,25 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
113130 return 0 ;
114131}
115132
116- int WINAPI WinMain (HINSTANCE hInstance , HINSTANCE hPrevInstance ,
117- LPSTR lpCmdLine , int nCmdShow )
133+ VOID SetButtonStyles (INT * btnStartStyle , INT * btnRemoveStyle , INT * btnInstallStyle )
118134{
135+ * btnStartStyle = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ;
136+ * btnRemoveStyle = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ;
137+ * btnInstallStyle = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ;
138+
139+ if (!IsLinux )
140+ {
141+ * btnInstallStyle |= WS_DISABLED ;
142+ * btnRemoveStyle |= WS_DISABLED ;
143+ return ;
144+ }
145+
119146 SC_HANDLE hSCManager = OpenSCManager (NULL , NULL , SC_MANAGER_ALL_ACCESS );
120147 SC_HANDLE schService = OpenService (hSCManager , "rpc-bridge" , SERVICE_START | SERVICE_QUERY_STATUS );
121148
122- INT btnStartStyle = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ;
123- INT btnRemoveStyle = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ;
124- INT btnInstallStyle = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ;
125-
126149 if (schService != NULL )
127150 {
128- btnInstallStyle |= WS_DISABLED ;
151+ * btnInstallStyle |= WS_DISABLED ;
129152
130153 SERVICE_STATUS_PROCESS ssStatus ;
131154 DWORD dwBytesNeeded ;
@@ -134,16 +157,23 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
134157
135158 if (ssStatus .dwCurrentState == SERVICE_RUNNING ||
136159 ssStatus .dwCurrentState == SERVICE_START_PENDING )
137- btnStartStyle |= WS_DISABLED ;
160+ * btnStartStyle |= WS_DISABLED ;
138161 }
139162 else
140163 {
141- btnStartStyle |= WS_DISABLED ;
142- btnRemoveStyle |= WS_DISABLED ;
164+ * btnStartStyle |= WS_DISABLED ;
165+ * btnRemoveStyle |= WS_DISABLED ;
143166 }
144167
145168 CloseServiceHandle (schService );
146169 CloseServiceHandle (hSCManager );
170+ }
171+
172+ int WINAPI WinMain (HINSTANCE hInstance , HINSTANCE hPrevInstance ,
173+ LPSTR lpCmdLine , int nCmdShow )
174+ {
175+ INT btnStartStyle , btnRemoveStyle , btnInstallStyle ;
176+ SetButtonStyles (& btnStartStyle , & btnRemoveStyle , & btnInstallStyle );
147177
148178 const char szClassName [] = "BridgeWindowClass" ;
149179
@@ -163,19 +193,19 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
163193
164194 assert (RegisterClassEx (& wc ));
165195
166- HWND hwnd = CreateWindowEx (WS_EX_CLIENTEDGE ,
167- szClassName ,
168- "Discord RPC Bridge" ,
169- WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME ,
170- (GetSystemMetrics (SM_CXSCREEN ) - 400 ) / 2 ,
171- (GetSystemMetrics (SM_CYSCREEN ) - 150 ) / 2 ,
172- 400 , 150 ,
173- NULL , NULL , hInstance , NULL );
196+ hwnd = CreateWindowEx (WS_EX_CLIENTEDGE ,
197+ szClassName ,
198+ "Discord RPC Bridge" ,
199+ WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME ,
200+ (GetSystemMetrics (SM_CXSCREEN ) - 400 ) / 2 ,
201+ (GetSystemMetrics (SM_CYSCREEN ) - 150 ) / 2 ,
202+ 400 , 150 ,
203+ NULL , NULL , hInstance , NULL );
174204
175205 CreateWindow ("STATIC" , "Do you want to start, install or remove the bridge?" ,
176206 WS_CHILD | WS_VISIBLE | SS_CENTER ,
177207 0 , 0 , 400 , 50 ,
178- hwnd , NULL , hInstance , NULL );
208+ hwnd , ( HMENU ) 4 , hInstance , NULL );
179209
180210 CreateWindow ("BUTTON" , "Start" ,
181211 btnStartStyle ,
0 commit comments