errorC2664:'StartServiceW':cannot convert paramter from 'const char **' to 'LPCWSTR*

rag84dec's Avatar, Join Date: Jul 2007
Go4Expert Member
HI all,

I have problem while compiling the following code which i copied from the
below location. i downloaded the source code and opened in visual studio 2008
and compiled , it worked fine. but i tried creating my own project of Win32
console application type but i started getting the following error...

Downloaded the code from the below link...
http://www.codeproject.com/KB/system...owService.aspx


I included following header files.
Code:
#pragma once


#include <process.h>
#include <iostream>
#include <tchar.h>
#include <stdio.h>
#include <windows.h>
#include <winbase.h>
#include <winsvc.h>

Code:
error C2664: 'StartServiceW' : cannot convert parameter 3 from 'const char **' to 'LPCWSTR *'
error C2664: 'OpenServiceW' : cannot convert parameter 2 from 'char *' to 'LPCWSTR'
error C2664: 'OpenServiceW' : cannot convert parameter 2 from 'char *' to 'LPCWSTR'
error C2440: 'initializing' : cannot convert from 'CHAR [501]' to 'LPWSTR'

Last edited by rag84dec; 9Nov2009 at 20:50.. Reason: typo
0
Gene Poole's Avatar, Join Date: Nov 2009
Contributor
You're using a UNICODE build. You need wide strings (wchar_t) instead of multi-byte strings (or turn off UNICODE in your project).