Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C and C++

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-05-2008, 03:42 AM
cpplover cpplover is offline
Newbie
 
Join Date: May 2008
Posts: 8
Rep Power: 0
cpplover is on a distinguished road
Default A problem with win32 Strings

Hello

I have a win32 Application and a problem with it:

it's my code :
Code:
hOpen = InternetOpen("Test Aplication", 
                      INTERNET_OPEN_TYPE_PRECONFIG,
                      NULL, NULL, 0);
But when I use this code my program has below error :

error C2664: 'InternetOpenW' : cannot convert parameter 1 from 'const char [16]' to 'LPCWSTR'

can someone help me to solve this problem ?

thanks .

Last edited by WingedPanther; 06-05-2008 at 04:52 PM. Reason: add code tags
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 06-05-2008, 04:58 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 3,376
Last Blog:
wxWidgets is NOT code ...
Rep Power: 37
WingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to behold
Default Re: A problem with win32 Strings

It looks like "Test Application" is an incorrect data type for the first parameter. In particular, according to MicroSoft, the first parameter is supposed to be a pointer to a string, not a string.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Programming is a branch of mathematics.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-09-2008, 02:47 PM
G_Morgan G_Morgan is offline
Guru
 
Join Date: Oct 2007
Age: 24
Posts: 506
Last Blog:
Just over the next hil...
Rep Power: 10
G_Morgan has a spectacular aura aboutG_Morgan has a spectacular aura aboutG_Morgan has a spectacular aura about
Default Re: A problem with win32 Strings

Entering a string literal in that way automatically passes in a pointer. Remember that a C string is just a character array and an array is just a pointer.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-10-2008, 03:57 PM
cpplover cpplover is offline
Newbie
 
Join Date: May 2008
Posts: 8
Rep Power: 0
cpplover is on a distinguished road
Default Re: A problem with win32 Strings

Thanks

i find best way to solve this problem and i say it :

we must write this code :

Code:
hOpen = InternetOpen((LPCWSTR)"Test Application", 
                      INTERNET_OPEN_TYPE_PRECONFIG,
                      NULL, NULL, 0);
and add wininet.lib in program.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
lpcwstr, string



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem read pwd protected Access2K dbase - CR9 & VB6 mrbar Visual Basic Programming 2 03-10-2008 05:50 AM
Problem with arrays and strings Nille C# Programming 4 02-04-2008 02:17 PM
How to tackle a programming problem? TcM General Programming 10 01-07-2008 12:29 PM
[C] Comparison problem Alhazred C and C++ 1 08-29-2007 05:58 AM
Strings clookid PHP Tutorials 2 01-13-2007 04:23 PM


All times are GMT -5. The time now is 02:27 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%

Ads