Question for Reading Combo1 ComProperty Error

2011-12-20
2013-04-30
  • Matthew Oarker
    Matthew Oarker
    2011-12-20

    Hello..
    Few days ago, I purchased Dell Inspiron 570(windows 7 Home) and installed my application which use TComPort 3.11 made by C++ Builder 2007. This program works on lots of machines(Windows 7 and XP). But in this model I got error message as follows:

    Error reading Combo1->ComProperty: Registry error (win error code:2)

    for the source used:

    TcomPort1->ShowSetupDialog();So, I installed windows XP and tested…
    But still same error message comes out.
    If anybody have similar problem or any clue, solution…
    Please let me know..
    thanks a lot in advance.

     
  • Ulfert
    Ulfert
    2011-12-20

    Search for this and comment out the line with the raise exception like shown below:

    procedure EnumComPorts(Ports: TStrings);
    var
      KeyHandle: HKEY;
      ErrCode, Index: Integer;
      ValueName, Data: string;
      ValueLen, DataLen, ValueType: DWORD;
      TmpPorts: TStringList;
    begin
      ErrCode := RegOpenKeyEx(
        HKEY_LOCAL_MACHINE,
        'HARDWARE\DEVICEMAP\SERIALCOMM',
        0,
        KEY_READ,
        KeyHandle);
      if ErrCode <> ERROR_SUCCESS then exit;
        //raise EComPort.Create(CError_RegError, ErrCode);    HERE!!
      TmpPorts := TStringList.Create;
      try
        Index := 0;
        repeat
          ValueLen := 256;
          DataLen := 256;
          SetLength(ValueName, ValueLen);
          SetLength(Data, DataLen);
          ErrCode := RegEnumValue(
            KeyHandle,
            Index,
            PChar(ValueName),
            {$IFDEF DELPHI_4_OR_HIGHER}
            Cardinal(ValueLen),
            {$ELSE}
            ValueLen,
              {$ENDIF}
            nil,
            @ValueType,
            PByte(PChar(Data)),
            @DataLen);
          if ErrCode = ERROR_SUCCESS then
          begin
            SetLength(Data, DataLen - 1);
            TmpPorts.Add(Data);
            Inc(Index);
          end
          else
            if ErrCode <> ERROR_NO_MORE_ITEMS then break;
              //raise EComPort.Create(CError_RegError, ErrCode);
        until (ErrCode <> ERROR_SUCCESS) ;
        TmpPorts.Sort;
        Ports.Assign(TmpPorts);
      finally
        RegCloseKey(KeyHandle);
        TmpPorts.Free;
      end;
    

    Most of the new Notebooks suppress the 'Serialcomm' key if no port is attached.