Click here to Skip to main content
16,010,022 members
Home / Discussions / C#
   

C#

 
GeneralRe: from Excel to Database Pin
totig10-Nov-04 0:17
totig10-Nov-04 0:17 
GeneralConverting projects Pin
Anonymous9-Nov-04 17:56
Anonymous9-Nov-04 17:56 
GeneralRe: Converting projects Pin
yoaz9-Nov-04 20:10
yoaz9-Nov-04 20:10 
GeneralRe: Converting projects Pin
Stefan Troschuetz9-Nov-04 21:29
Stefan Troschuetz9-Nov-04 21:29 
GeneralProblem with arraylist Pin
amalatsliit9-Nov-04 16:59
amalatsliit9-Nov-04 16:59 
GeneralRe: Problem with arraylist Pin
Corinna John9-Nov-04 19:38
Corinna John9-Nov-04 19:38 
GeneralHelp me please!!! Pin
momer9-Nov-04 15:47
momer9-Nov-04 15:47 
GeneralRe: Help me please!!! Pin
szyusong3-Jul-09 6:06
szyusong3-Jul-09 6:06 
I'm a delphi programmer. I have the same problem when programming, but I find a way to correct it. Take a look at following code which in bold. I hope it can help you.
const
  GUID_CLASS_COMPORT: TGUID = (
    D1:$86e0d1e0; D2:$8089; D3:$11d0; D4:($9c, $e4, $08, $00, $3e, $30, $1f, $73));

procedure EnumPortsWdm(AList: TStrings);
var
  LGuid: TGUID;
  LDeviceInfo: HDEVINFO;
  LDevice: TSPDevInfoData;
  LDeviceInterfaceData: TSPDeviceInterfaceData;
  LDeviceInterfaceDetailData: PSPDeviceInterfaceDetailData;
  LSuccess, LIsUsbDevice: Boolean;
  LDeviceInterfaceDetailDataSize,
  LRequiredSize: DWORD;
  LIndex: DWORD;
  LFriendlyName: array[0..255] of Char;
  LDesc: array[0..255] of Char;
  LLocInfo: array[0..255] of Char;
  LComPortInfo: TComPortInfo;
begin
  ClearPortsList(AList);

  LGuid := GUID_CLASS_COMPORT;
  LDeviceInfo := SetupDiGetClassDevs(@GUID_CLASS_COMPORT,
    nil, 0, DIGCF_PRESENT or DIGCF_DEVICEINTERFACE);
  if (Cardinal(LDeviceInfo) = INVALID_HANDLE_VALUE) then
  begin
    Exit;
  end;  
  SetupDiGetDeviceInterfaceDetail(LDeviceInfo,
    @LDeviceInterfaceData, nil, 0, @LRequiredSize, @LDevice);
  LDeviceInterfaceDetailDataSize := LRequiredSize;
  GetMem(LDeviceInterfaceDetailData, LRequiredSize);
  try
    // This is required, according to the documentation. Yes,
    // it's weird.
    LDeviceInterfaceData.cbSize := sizeof(TSPDeviceInterfaceData);
    LDeviceInterfaceDetailData.cbSize := sizeof(TSPDeviceInterfaceDetailData);
    // Enumerate the serial ports
    LIndex := 0;
    while True do
    begin
      if not SetupDiEnumDeviceInterfaces(LDeviceInfo,
        nil, LGuid, LIndex, LDeviceInterfaceData) then
      begin
        Break;
      end;
      LDevice.cbSize := sizeof(TSPDevInfoData);
      LDevice.ClassGuid := GUID_CLASS_COMPORT;
      // Got a device. Get the details.
      if not SetupDiGetDeviceInterfaceDetail(LDeviceInfo,
        @LDeviceInterfaceData,
        LDeviceInterfaceDetailData,
        LDeviceInterfaceDetailDataSize,
        @LRequiredSize, @LDevice) then
      begin
        Break;
      end;
      // Got a path to the device. Try to get some more info.
      LSuccess := SetupDiGetDeviceRegistryProperty(LDeviceInfo,
        LDevice, SPDRP_FRIENDLYNAME, nil,
        PByte(@LFriendlyName[0]), sizeof(LFriendlyName), nil);
      LSuccess := LSuccess and SetupDiGetDeviceRegistryProperty(
              LDeviceInfo, LDevice, SPDRP_DEVICEDESC, nil,
              PByte(@LDesc[0]), sizeof(LDesc), nil);
      LIsUsbDevice := FALSE;
      if SetupDiGetDeviceRegistryProperty(
              LDeviceInfo, LDevice, SPDRP_LOCATION_INFORMATION, nil,
              PByte(@LLocInfo[0]), sizeof(LLocInfo), nil) then
      begin
        // Just check the first three characters to determine
        // if the port is connected to the USB bus. This isn't
        // an infallible method; it would be better to use the
        // BUS GUID. Currently, Windows doesn't let you query
        // that though (SPDRP_BUSTYPEGUID seems to exist in
        // documentation only).
        LIsUsbDevice := (Pos('USB', LLocInfo) = 1);
      end;
      if LSuccess then
      begin
        LComPortInfo := TComPortInfo.Create;
        LComPortInfo.DevPath := PChar(@LDeviceInterfaceDetailData.DevicePath[0]);
        LComPortInfo.FriendlyName := LFriendlyName;
        LComPortInfo.PortDesc := LDesc;
        LComPortInfo.IsUsbDevice := LIsUsbDevice;
        AList.AddObject(LFriendlyName, LComPortInfo);
      end;
      LIndex := LIndex + 1;
    end;
  finally
    FreeMem(LDeviceInterfaceDetailData);
    SetupDiDestroyDeviceInfoList(LDeviceInfo);
  end;
end;

GeneralSending Serialized data across a socket between two programs Pin
Guinness4Strength9-Nov-04 9:10
Guinness4Strength9-Nov-04 9:10 
Generaltesting for equality Pin
John L. DeVito9-Nov-04 8:58
professionalJohn L. DeVito9-Nov-04 8:58 
GeneralRe: testing for equality Pin
Steve Maier9-Nov-04 9:40
professionalSteve Maier9-Nov-04 9:40 
GeneralRe: testing for equality Pin
John L. DeVito9-Nov-04 10:13
professionalJohn L. DeVito9-Nov-04 10:13 
Generalc programming Pin
kp20dub9-Nov-04 7:40
kp20dub9-Nov-04 7:40 
GeneralRe: c programming Pin
DougW489-Nov-04 20:55
DougW489-Nov-04 20:55 
GeneralRemove Video question.. Pin
OMalleyW9-Nov-04 7:05
OMalleyW9-Nov-04 7:05 
GeneralC# FTP Client - a part of received message missing Pin
miki_wawa9-Nov-04 6:08
sussmiki_wawa9-Nov-04 6:08 
GeneralSimple Parse a simple HTTP Response Pin
berlinbrown9-Nov-04 5:58
berlinbrown9-Nov-04 5:58 
GeneralRe: Simple Parse a simple HTTP Response Pin
Stefan Troschuetz9-Nov-04 21:49
Stefan Troschuetz9-Nov-04 21:49 
GeneralRe: Simple Parse a simple HTTP Response Pin
berlinbrown10-Nov-04 2:14
berlinbrown10-Nov-04 2:14 
GeneralRe: Simple Parse a simple HTTP Response Pin
Stefan Troschuetz10-Nov-04 2:26
Stefan Troschuetz10-Nov-04 2:26 
QuestionIs there any function in c#.net like "_i64toa? Pin
FlyToYou9-Nov-04 4:47
FlyToYou9-Nov-04 4:47 
AnswerRe: Is there any function in c#.net like "_i64toa? Pin
Stefan Troschuetz9-Nov-04 4:57
Stefan Troschuetz9-Nov-04 4:57 
AnswerRe: Is there any function in c#.net like "_i64toa? Pin
Tom Larsen9-Nov-04 5:02
Tom Larsen9-Nov-04 5:02 
GeneralGive up now Pin
leppie9-Nov-04 4:12
leppie9-Nov-04 4:12 
GeneralRe: student request Pin
DougW489-Nov-04 21:13
DougW489-Nov-04 21:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.