473,326 Members | 2,255 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,326 software developers and data experts.

Migration to C++ 7.0

First i need to tell you i am no C-Programer - i can only make some litle C
changes to the code to meet our needs.

Now i have the folowing problem. Our programm reads a SQL-String from the
resources and gives this to the oledbCommand. This is the macro which worked
fine with C++6.0:

#define DEF_RESCOMMAND(x, nResource) typedef x _CommandClass; \

static HRESULT GetDefaultCommand(LPCWSTR* ppszCommand) \

{ static char sCommand[1024]; \

static bool bInit=false; \

if (!bInit) {::LoadString(_Module.m_hInst,nResource,sCommand,1 024);
bInit=true;} \

*ppszCommand = sCommand; \

return S_OK; \

}

When i compile this with C++7.0 i get the following error - pleace be
patient but i cant tell you the english errormessage only the german:

c:\Entwicklung V2.0\visKernel\qryTradeGroups.H(25): error C2440: '=' : 'char
[1024]' kann nicht in 'LPCWSTR' konvertiert werden

but means that CHAR could not be converted to LPCWSTR.

Now I changed this to the following form:

#define DEF_RESCOMMAND(x, nResource) typedef x _CommandClass; \
static HRESULT GetDefaultCommand(LPCWSTR* ppszCommand) \

{ static char sCommand[1024]; \

static bool bInit=false; \

if (!bInit) {::LoadString(_Module.m_hInst,nResource,sCommand,1 024);
bInit=true;} \

*ppszCommand = CA2W(sCommand); \

return S_OK; \

}

I used a conversionfunction. Now it compiles ok, but at runtime the lifetime
of the converted string is to short, when the code leafes the code of the
macro, the string only contains 999999.... inside its okay. please tell me
what function to convert i need to use instead of CA2W or what else i should
change in the macro.
thx for your effort

Markus
Nov 16 '05 #1
1 1595
Markus Strauss wrote:
When i compile this with C++7.0 i get the following error - pleace be
patient but i cant tell you the english errormessage only the german:

c:\Entwicklung V2.0\visKernel\qryTradeGroups.H(25): error C2440: '=' :
'char [1024]' kann nicht in 'LPCWSTR' konvertiert werden

but means that CHAR could not be converted to LPCWSTR.


Hi Markus,
The problem is that the original array contains ANSI characters, and the
pointer is asking for wide characters. LPCWSTR stands for long pointer to
constant wide zero-terminated string. The assignment is trying to assign a
long pointer to a constant ansi zero-terminated string.

The fix is not that hard. Change this line

{ static char sCommand[1024]; \

to

{ static wchar_t sCommand[1024]; \

This way you are working with a wide character buffer. Some of the other
function calls (such as LoadString) will likely need to be changed to using
the wide string API (such as LoadStringW). This usually happens behind the
scenes depending on whether the _UNICODE macro is defined. For more
information, check out the documentation for tchar.h.

I hope that helps get you going in the right direction. Cheerio!

--
Brandon Bray Visual C++ Compiler
This posting is provided AS IS with no warranties, and confers no rights.
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Paddy McCarthy | last post by:
Frustrated at being prevented from using Python at work I went gunning for Perl. Time to roll out some useless Google statistics to make me feel better Google Phrase count...
4
by: susmita_ganguly | last post by:
Hi I am trying to upgrade from oracle 8i to oracle 9i on the same server ..I don't know much abt migration . Can anyone help me out. Thanks. Susmita
11
by: Jep | last post by:
Any help or advice appreciated. We have just installed and configured a new DB2 v.8.1 with latest FixPack. Just a few days later it dies and now we have a DB that is totally unusable. - - - -...
4
by: Abram Friesen | last post by:
Hi, I'm a developer for a software application vendor, and our application makes use of a customer-maintained Oracle 8i/9i database. We've had a customer request to support DB2 database, and I'm...
1
by: sac | last post by:
I am using DB2 v8.1 on UNIX. A few weeks ago the DBAs carried out node migration activity on the database. After the node migration I observed that the queries that execute on temporary tables...
1
by: rob | last post by:
Dear All, I have a very small test project to convert asp to asp.net using the Microsoft/Artisan ASP to ASP.NET Migration Assistant...
1
by: Bonggoy Cruz | last post by:
We have a fairly big size ASP.NET web application that was written VB.NET. We are in the process converting the web project. We used the migration wizard included in VS 2005. I followed step by...
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
9
by: Troels Arvin | last post by:
At work, some people have found IBM's Migration Toolkit (MTK) to be a nice tool for copying data from one table (in another DBMS product) to DB2. Now, they want to do the same thing from one DB2...
3
Frinavale
by: Frinavale | last post by:
I have been researching the best approach to migrating a VB6 application into a VB.NET application. There is a lot of information out there but most of it recommends that you "train in the migration...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.