my O.S is Windows 7 64 bits, i use Lazarus 1.2.4 32 bits. I have created two virtual serial ports paired with the software com0com .
Did you check the value of the registry with regedit (as seen from attached image)? A virtual com port might be created properly, there is a problem with Bluetooth com port installation. I just plugged a USB to Serial adapter, win assigned COM3 to it, then I manually changed the prot number to 41 and it is okay (right picture). But adding COM devices to bluetooth (in Win XP) does not add last two zeroes (left screenshot).
I did the same on another PC with WinXP 32 bit. Bluetooth added COMS the same way. Then I run this source in VB.NET:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim readValue As String
readValue = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM", "\Device\BthModem10", Nothing)
MsgBox("The value is " & readValue)
End Sub
It returned the
entire string. So I have nothing else to think, except that there is a bug in the FPC registry implementation, or precisely
registry.pp.
Here is their code:
function TRegistry.ReadString(const Name: string): string;
Var
Info : TRegDataInfo;
begin
GetDataInfo(Name,Info);
if info.datasize>0 then
begin
If Not (Info.RegData in [rdString,rdExpandString]) then
Raise ERegistryException.CreateFmt(SInvalidRegType, [Name]);
SetLength(Result,Info.DataSize);
If StringSizeIncludesNull then
SetLength(Result, Info.DataSize-1)
else
SetLength(Result, Info.DataSize);
GetData(Name,PChar(Result),Info.DataSize,Info.RegData);
end
else
result:='';
end;
In the source of registry.pp I could not find where
StringSizeIncludesNull gets its value from, but it always returns true!?!
Edit: I have fixed the code the following way, no it seems to work fine:
function TRegistry.ReadString(const Name: string): string;
Var
Info : TRegDataInfo;
begin
GetDataInfo(Name,Info);
if info.datasize>0 then
begin
If Not (Info.RegData in [rdString,rdExpandString]) then
Raise ERegistryException.CreateFmt(SInvalidRegType, [Name]);
SetLength(Result,Info.DataSize);
GetData(Name,PChar(Result),Info.DataSize,Info.RegData);
FStringSizeIncludesNull:=(RightStr(Result,1)=#0);
If StringSizeIncludesNull then
SetLength(Result, Info.DataSize-1)
else
SetLength(Result, Info.DataSize);
end
else
Result:='';
end;
Edit: Reported as bug
27002.
Edit: It occurs that the problem was
reported 2,5 years ago, still no resolution.
Jurassic Pork, what about using a custom ReadString function in your library, until the bug is fixed? Also, do you mean uploading it to SF or somthing similar?