By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,923 Members | 1,162 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,923 IT Pros & Developers. It's quick & easy.

'CreateFileW' : cannot convert parameter 1 from 'const char [13]' to 'LPCWSTR'

P: 61
Hai this is senthil...

I had tried to write a string which fetched from a database. into a file...

when i tried to compile the solution the following error occurs like this

error C2664: 'CreateFileW' : cannot convert parameter 1 from 'const char [13]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast


Expand|Select|Wrap|Line Numbers
  1. Code:
  2. My codings are below...
  3. ----------------------------------------------------------------------
  4. void main()
  5. {
  6.  
  7.   MYSQL *conn; 
  8.   conn = mysql_init(NULL);
  9.   mysql_real_connect(conn,host,username,password,database,0,NULL,0);     
  10.   MYSQL_RES *res_set; 
  11.   MYSQL_ROW row;
  12.   mysql_query(conn,"SELECT * FROM imagedb2");
  13.   res_set = mysql_store_result(conn);
  14.   unsigned int numrows = mysql_num_rows(res_set);
  15.  
  16.    //For Creating a file....
  17.   HANDLE hFile; 
  18.   DWORD wmWritten;   
  19.   hFile =CreateFile"d:\\text3.doc",GENERIC_READ|GENERIC_WRITE,             
  20.   FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); 
  21.  
  22.    while (( row = mysql_fetch_row(res_set)) != NULL)
  23. {        
  24.  
  25.        char str[255];
  26.        char *tmp = str;
  27.        strcpy(str, row[2]); 
  28.  
  29.  
  30.        WriteFile(hFile,str,(DWORD)(sizeof(str)),&wmWritten,NULL); 
  31.        CloseHandle(hFile); 
  32.  
  33.  
  34.         }
  35.            mysql_close(conn);
  36. getch();
  37.  
  38.    }   
  39.  
  40. In Project->Properties->General->Character Set::Use Multi-Byte Character Set
This configuration proterties i'm using....

What shall i do for the above error...

Can any one plzz help me??
Jan 3 '07 #1
Share this Question
Share on Google+
1 Reply


P: 24
Hope the following links may help you to resolve the problem.

http://www.tutorials-blog.com/win32/win32-20.html
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=210023&SiteID=1
Jan 3 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.