I recently tried out the newest version of Embarcadero - 10.2. When I ran an older Delphi 2007 program under it everything compiled all-right, but I got Chinese characters where I expected to get English! That was from a USB call where I was trying to retrieve the descriptor. I have read that the default string type has changed from 8-bit to 16-bit unicode, but I don't know how to fix the problem. My (partial) code is as follows:
procedure TfrmMain.tb02PollDevicesClick(Sender: TObject);
var
NumDevices: DWORD;
I: DWORD;
DeviceStr: SI_DEVICE_STRING; // array of char
Options: DWORD;
sDeviceList: TStrings;
begin
NumDevices := 0;
//
SiStat := SI_GetNumDevices(NumDevices);
if SiStat <> SI_SUCCESS then
begin
HandleError('GetNumDevices in tb02PollDevices1Click', SiStat);
Exit;
end;
//
sDeviceList := TStringList.Create;
for I := 0 to NumDevices - 1 do
begin
Options := $00000000;
SiStat := SI_GetProductString(I, @DeviceStr, Options);
if (SiStat <> SI_SUCCESS) then
begin
HandleError('GetProductString in tb02PollDevices1Click', SiStat);
Exit;
end;
sDeviceList.Append(DeviceStr);
cboDevices.Items.Add(string(DeviceStr));
end;
//
Any help would be appreciated. Thanks, hlo.
Connect with Us