views:

213

answers:

2

Hi I have a application that works well on windows xp pro, windows Visa, windows 7

But when I run it on windows xp embedded it does not work and gives the following error:

EEncodingError - Invalid code page

When the App is made with Delphi 2006 it work on windows XP embedded

When the App is made with Delphi 2010 it does *not work on windows XP embedded*

A: 

When does it crash? On startup, or later?

That error is only found in one place, in the RTL at least. In SysUtils, constructor TMBCSEncoding.Create(CodePage, MBToWCharFlags, WCharToMBFlags: Integer);, which gets called by TEncoding to set up string encodings.

It takes the CodePage parameter and calls GetCPInfo on it, and if it fails it raises this exception. From the MSDN documentation and the exception message, what's probably going on is that your app is trying to use strings from a multibyte character set that's not supported by XP Embedded. Are you doing anything unusual with strings or text work in foreign languages that use a different alphabet?

Mason Wheeler
@Masson it crash OnStartup, I am doing nothing unusual+ all the text is in english
Charles Faiga
@Charles: Weird. Can you run BDS under XP Embedded? This sounds like a job for Delphi's debugger.
Mason Wheeler
@Charles - if it crashes before application.run, then it's likely something in the initialization section of a unit. And you say that the text is English, ok. But is this an English XP Embedded? That probably matters too.
Chris Thornton
Also, try making a "hello, world" delphi project, and see if that runs on the embedded XP. That should cut your troubleshooting in half.
Chris Thornton
The call made is GetCPInfo(FCodePage, LCPInfo), where LCPInfo is a variable of type TCPInfo, which is a record. The GetCPInfo function expects a pointer to where it can write its output for the second parameter. So I would have expected the call to be GetCPInfo(FCodePage, @LCPInfo)? Not sure though why it then doesn't fail on non-embedded XP?
Marjan Venema
@Marjan: It's a Delphi idiom. When C code in a DLL expects a pointer to a value so it can modify it, as long as you don't need to pass it a **nil**, you can declare it as a **var** parameter instead of a pointer, and you end up with more readable code that way. If you look at GetCPInfo's declaration in Windows.pas, that's exactly what it does here.
Mason Wheeler
@Mason: Thanks for the explanation. I sometimes thinks Delphi shields us a little too much from the pointy things, but then again, I am glad it does...
Marjan Venema
+1  A: 

The TEncoding.ASCII property uses codepage 20127, which is not installed on XP Embedded by default. You have to install it manually. The TEncoding class does not exist in D2006.

Are you using Indy 10, by chance? It uses TEncoding.ASCII by default for its string encodings. This exact error has been known to occur when using Indy on XP Embedded.

Remy Lebeau - TeamB
@Remy - Thanks - Enabling copepage 20127 - fixed the problem :)
Charles Faiga