Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

problems with splitting a large unit into 2 units

Posted on 1999-01-16
6
Medium Priority
?
294 Views
Last Modified: 2010-04-06

Hi experts,

I have created this unit:


unit Global;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, FileCtrl, StdCtrls, ExtCtrls, clipbrd, Buttons;

 function EnumFiles(path: string; findFile: string) : string;
 function findFileOnAllHarddisks(fileName: string) : string;

implementation

{$R *.DFM}

 function EnumFiles(path: string; findFile: string) : string;
      var fd1 : TWin32FindData;
          c1  : cardinal;
          s1  : string;
      begin
        if fileExists(path+findFile) then begin
          result:=path+findFile;
          exit;
        end;
        c1:=FindFirstFile(PChar(path+'*.*'),fd1);
        if c1<>INVALID_HANDLE_VALUE then
          try
            repeat
              s1:=string(fd1.cFileName);
              if (s1<>'.') and (s1<>'..') and (fd1.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY<>0) then
      begin
                result:=EnumFiles(path+s1+'\',findFile);
                if result<>'' then break;
              end;
            until not FindNextFile(c1,fd1);
          finally Windows.FindClose(c1) end;
      end;


function findFileOnAllHarddisks(fileName: string) : string;
      var c1,c2 : cardinal;
          ch1   : char;
      begin
        result:='';
        c2:=GetLogicalDrives;
        for ch1:='A' to 'Z' do
          if odd(c2 shr (ord(ch1)-ord('A'))) then begin
            c1:=GetDriveType(PChar(ch1+':\'));
            if c1=DRIVE_FIXED then begin
              result:=EnumFiles(ch1+':\',fileName);
              if result<>'' then break;
            end;
          end;
      end;


end.

Unfortunately in the line:

 finally Windows.FindClose(c1) end;

Delphi says:

"record,object or class-type is needed".

I don't understand why this happens. In former times,
the functions

 function EnumFiles(path: string; findFile: string) : string;
 function findFileOnAllHarddisks(fileName: string) : string;

were part of a single major unit, and everyting worked very well. As this
major untit became too large to have a good overview, I decided to split this
major unit and move


 function EnumFiles(path: string; findFile: string) : string;
 function findFileOnAllHarddisks(fileName: string) : string;

to the new created unit "global". and now suddenly I get this strange error message,
although all worked very welll earlier, when everything was in one big unit.


Can you please tell me what is wrong here?

With kind regards

Mathes


0
Comment
Question by:mathes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1356873
Hi Mathes,

FindClose, wants a TSearchRec as Parameter not a typ Cardinal

meikl
0
 

Author Comment

by:mathes
ID: 1356874
hi meikl,

you are probably right, but why does this happen only after I splitted the large unit,
whereas everything worked bugfree when it was one single unit.

with kind regards

mathes
0
 

Author Comment

by:mathes
ID: 1356875
hi meikl,

you are probably right, but why does this happen only after I splitted the large unit,
whereas everything worked bugfree when it was one single unit.

with kind regards

mathes
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 1356876
Hi Mathes

try to add the Unit Windows in the unit-Clause,

then should error solved and the FindClose from Windows-API will used.

meikl
0
 

Author Comment

by:mathes
ID: 1356877
Dear meikl,

thank you for your help.

Yes, you were right. As soon as I added the "windows" unit, everything
worked very well.

With kind regards

Mathes
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 40 total points
ID: 1356878
Hi Mathes,

well then, can i get some points?

meikl
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question