dokan-dev / dokany

User mode file system library for windows with FUSE Wrapper
http://dokan-dev.github.io
5.2k stars 661 forks source link

Feature Request: Run mirror.exe in background #931

Closed hacker-h closed 3 years ago

hacker-h commented 3 years ago

Is it possible to run mirror.exe in background, respectively omit the opening of an additional terminal window, e.g. by keeping the output in the terminal that actually launches the executable? If it is not yet possible, where can it be adapted in code?

I think this feature would be highly convenient, so you do not have a terminal window open all the time.

Liryna commented 3 years ago

Hi @hacker-h ,

I can understand the need but mirror is just a sample of the library and this feature so not help in learning the dokan api.

But since mirror code can be used and changed for whatever need: On windows there is different ways to start a process without window. Some are listed here https://stackoverflow.com/questions/2139637/hide-console-of-windows-application Hope this answer your question.

hacker-h commented 3 years ago

Following the SO link you provided, tweaking the Linker SubSystem from Console to Windows is apparently not enough:

Error LNK2019 unresolved external symbol _WinMain@16 referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) dokan_mirror C:\Users\Hacker\source\repos\dokany\samples\dokan_mirror\LIBCMTD.lib(exe_winmain.obj) 1

Also my VS2019 cannot detect any entrypoint for dokan_mirror. Are there additional adaptations necessary or is my setup incorrect?

Liryna commented 3 years ago

@hacker-h You need to change the current main function prototype to WinMain as explain in the link.

hacker-h commented 3 years ago

Thanks for the pointers! With those and two more articles I was able to understand and solve the issue: https://stackoverflow.com/a/13872211 https://codingmisadventures.wordpress.com/2009/03/10/retrieving-command-line-parameters-from-winmain-in-win32/

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, LPSTR lpCmdLine,
                   int nShowCmd) {
  LPWSTR *argv;
  int argc;

  argv = CommandLineToArgvW(GetCommandLine(), &argc);

  return wmain(argc, argv);
}