0

I have the following code to check if the process path has the value iexplore.exe:

void GetDataElement(WCHAR process_name[MAX_PATH]){

CHAR *IEName = "iexplore.exe";
...

GetModuleFileNameExW(hProcess,NULL,process_name,MAX_PATH)

...

if(strstr(process_name,IEName)!=NULL){
   ...
}

However, I am getting the following warning:

'function': incompatible types - from 'WCHAR *' to 'const char *'

I do not know how to convert my variable process_name into const char *, in order to remove that warning.

sergioMoreno
  • 189
  • 1
  • 15
  • 3
    Does this answer your question? [how to convert const WCHAR \* to const char \*](https://stackoverflow.com/questions/12637779/how-to-convert-const-wchar-to-const-char) – Random Davis Dec 02 '20 at 16:57
  • @RandomDavis Tks for your help. I saw that post but I do not have a const WCHAR* but WCHAR. That is why I am asking how to do it? – sergioMoreno Dec 02 '20 at 17:00
  • Maybe duplicated of https://stackoverflow.com/questions/12637779/how-to-convert-const-wchar-to-const-char – Thomaz Capra Dec 02 '20 at 17:00
  • https://stackoverflow.com/questions/12637779/how-to-convert-const-wchar-to-const-char/22862005 – Tarik Dec 02 '20 at 17:00
  • 3
    Why don't you make `IEName` a `WCHAR *` and use [`wcsstr`](https://learn.microsoft.com/de-de/cpp/c-runtime-library/reference/strstr-wcsstr-mbsstr-mbsstr-l?view=msvc-160) instead of `strstr`? – M Oehm Dec 02 '20 at 17:02
  • i would suggest casting to a const char, not sure how to do that speifically because i dont know the data structure you are using for that "WCHAR". – Austin Sisinni Dec 02 '20 at 16:59

0 Answers0