Dear All Friends

i have an problem with windows vista .
i write an program for Readind Data From Serial port in delphi . and then compile it in windows XP . Application is worked very good . but when i do compiled this application in windows Visat , i can't Read any Data from Serial port .

do you know that what happen when compiled with windows vista ?

Dani AI

Generated

As asked, make sure we’re talking about a build-time problem: since confirmed the executable built on Vista fails to read serial data even when run on XP, this strongly points at a difference in the build environment or how the app talks to COM ports — not a simple runtime setting. As suggested, add logging; below are targeted checks and a small test you can compile quickly to isolate the issue.

Most likely culprits (check these in order)

  • Build differences: different Delphi options, runtime packages (BPLs), or DCUs on the Vista machine. Disable “Use runtime packages” and “Use dynamic RTL” or make sure the same packages exist on the target system. Do a full Clean + Build.
  • Third‑party components: ensure the same serial library/version is installed on the Vista dev box and used in the project.
  • COM name / driver issues: virtual/USB‑serial drivers can assign different COM numbers (COM10+ needs the \.\COM10 syntax). Test the port with a terminal app (PuTTY/TeraTerm) to verify the driver.
  • Permissions / manifest / UAC: run the failing EXE “As administrator” once to rule out privilege differences. Check for an embedded manifest that changes behavior.
  • I/O method: if your code uses direct port I/O (inp/outp) or nonstandard drivers that worked on one box, that will fail on NT/FW kernels without a driver.

Concrete quick tests

  • Build a minimal program that just opens the COM port, logs CreateFile result and GetLastError, and attempts a single ReadFile. Compare the XP-built and Vista-built EXEs on the same machine.
  • Log: port name, CreateFile handle value, SysErrorMessage(GetLastError), ClearCommError status, bytes read.

Example minimal test (Delphi):

uses Windows, SysUtils;

procedure TestCOM(const PortName: string);
var
  h: THandle; bytesRead: DWORD; buf: array[0..255] of Byte;
begin
  h := CreateFile(PChar('\\.\' + PortName), GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, 0, 0);
  if h = INVALID_HANDLE_VALUE then
    raise Exception.CreateFmt('Open %s failed: %s (%d)', [PortName, SysErrorMessage(GetLastError), GetLastError]);
  try
    if not ReadFile(h, buf, 1, bytesRead, nil) then
      raise Exception.CreateFmt('Read failed: %s (%d)', [SysErrorMessage(GetLastError), GetLastError]);
  finally
    CloseHandle(h);
  end;
end;

If the test above behaves differently between builds, compare Project→Options (Linker/Packages/Compiler) and installed component versions on the two dev machines. If you still can’t find the cause, post the exact CreateFile/GetLastError output and the Project Options used on the Vista build.

Recommended Answers

All 4 Replies

Do you mean when run in vista or when compiled in vista?

What was the errror?

when i compiled this program in windows xp , it's ok (Reading data whery well) . but when i compiled this program in windows vista then i can't Reciveing any Data from Serial port in windows vista or windows xp .

Then you need to include with it a number of debugging statements that either write to a file or messages to screen or use something like smartinspect to direct various debug informations there...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.