472,958 Members | 1,800 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 10264
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.