473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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
1 10305
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

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

Similar topics

5
by: Brad Moore | last post by:
Hey all, I'm getting the following compiler error from my code. I was wondering if anyone could help me understand the concept behind it (I actually did try and compile this degenerate...
3
by: Michael Breidenstein | last post by:
Hi, anybody can help me to convert a "char *" to LPCWSTR with the following function: LPCWSTR charP2LPCWSTR(char *szText){ LPCWSTR tmp; tmp=szText; // At this point I need help
6
by: John Smith | last post by:
What's wrong with the use of atoi in the following code? Why do I get the error message: 'atoi' : cannot convert parameter 1 from 'char' to 'const char *' char cBuffer; void...
12
by: GRoll35 | last post by:
I get 4 of those errors. in the same spot. I'll show my parent class, child class, and my driver. All that is suppose to happen is the user enters data and it uses parent/child class to display...
3
by: kaizen | last post by:
Hi, i wrote the code in C and compiled in VC++ compiler. at that time it has thrown the below mentioned error. error C2664: 'strcpy' : cannot convert parameter 2 from 'char' to 'const char *'...
3
by: bg_ie | last post by:
Hi, I am using a API I downloaded from the internet programmed in C. I need the function below which works with this api in my c++ file - void StoreNoteCallback(void *context, int arglen,...
5
by: sachin30 | last post by:
How do i convert const char * to LPCWSTR?
5
by: slizorn | last post by:
well the error i get is the title above: error C2664: 'searchTree' : cannot convert parameter 2 from 'const char *' to 'char' error is form this line searchTree(treeObj->root ,data1.c_str());...
12
by: Amera | last post by:
hi, i wrote a c code which calls a function from mytest,dll this function returns the character "s" . this is my code : #include<stdio.h> #include<windows.h>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.