title: CreateFile/WriteFile api in Delphi XE
body: <p>We are using the Below code for printing the tickets data in LPT1 port. These code in working fine in Win-7 Delphi-7 Exe but same code is not working on Win-7 Delphi XE.
  I've try the solution available in net. but it is not helping me to resolved the issues. Please can you suggested any solution for that.</p>
  
  <pre><code>function TdmDisneyCastTrac.SendToParallelPort(pContent : TStringList): boolean;
  var
    slPrintLines : TStringList;
    hFile : THandle;
    Overlapped : TOverlapped;
    I : integer;
    bContentPrinted : boolean;
    dw : DWORD;
  begin
     slPrintLines := TStringList.Create;
     result := True;
     try
        slPrintLines.AddStrings(pContent);
        FillChar(Overlapped, SizeOf(Overlapped),0);
        I := 0;
        repeat
           hFile := INVALID_HANDLE_VALUE;
           bContentPrinted := True;
           hFile := CreateFile(PChar('LPT1:'), GENERIC_WRITE, FILE_SHARE_WRITE, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
           if hFile = INVALID_HANDLE_VALUE then
              bContentPrinted := False
           else
           begin
              Overlapped.hEvent := CreateEvent(nil, False, False, nil);
              if Overlapped.hEvent = 0 then
                 bContentPrinted := False
              else
              begin
                 if not WriteFile(hFile, slPrintLines.Text[1], length(slPrintLines.Text), dw, @Overlapped) then
                 case WaitForSingleObject(Overlapped.hEvent, 4000) of  // wait 3 seconds
                    WAIT_OBJECT_0 : ;
                    WAIT_TIMEOUT,
                    WAIT_ABANDONED : begin
                                       bContentPrinted := False;
                                       if hFile &lt;&gt; INVALID_HANDLE_VALUE then
                                         CloseHandle(hFile);
                                         if Overlapped.hEvent &lt;&gt; 0 then
                                              CloseHandle(Overlapped.hEvent);
                                     end;
               end;
             end;
            end;
            inc(I);
          until bContentPrinted or (I = 3);
          result := bContentPrinted;
    finally
       slPrintLines.Free;
        if hFile &lt;&gt; INVALID_HANDLE_VALUE then
           CloseHandle(hFile);
        if Overlapped.hEvent &lt;&gt; 0 then
           CloseHandle(Overlapped.hEvent);
     end;
  end;
  </code></pre>
  
  <p>Noted:- This is the Win API function.</p>