c++ - Simple app to know if Notepad++ is running -
i have simple application 1 button know if notepadd++ open. have review topics cannot find right one. inside button method have:
private: system::void button1_click(system::object^  sender, system::eventargs^  e) {     mutex = createmutex( null, true, "local\\$notepad++$");     if (getlasterror() == error_already_exists) {         //messagebox::show(..[not open]..);     }     //messagebox::show(..[open]..); } };   i have problem "local\$notepad++$", errors:
argument of type "const char *" incompatible parameter of type "lpcwstr"   and other:
'handle createmutexw(lpsecurity_attributes,bool,lpcwstr)': cannot convert argument 3 'const char [18]' 'lpcwstr'   if there easier way please me! have try changing name to: notepad++. using visual studio 2015 c++
i have review , use reference:
c/c++ how tell if program running?
is using mutex prevent multiple instances of same program running safe?
#include "windows.h" /*...*/ lpcstr app_name = "notepad++: free (gnu) source code editor"; if (findwindowa(0, app_name)) {     // it's open! } else {     // it's not open! }   for method, put * before quotes
createmutex( null, true, *"local\\$notepad++$");      
Comments
Post a Comment