Is it possible for unit names to be added to each function call in another block?

One of the problems that I often encounter is that I will include Windows ' in my uses clause, and then later add ' JwaWinBase ' for some specific calls.

However, many of the functions in the "Windows" module are the same as in JwaWinBase, and I start to get errors in my main module all over the place until I fix all my calls, after waiting for the correct unit name, for example:

Old:

  • CreateProcessAsUser (...)

New:

  • Windows.CreateProcessAsUser (...)
  • JwaWinBase.CreateProcessAsUser (...)

What I want to know is there a way to automatically assign a device name to each function call in another block? Thus, before I add JwaWinBase to my suggestion, I could have a single name named "Windows" for any function calls. Then adding JwaWinBase will not give me any errors.

I am currently using Delphi 2007.

+3
source share
4 answers

No.

However, function calls are processed in reverse order, they are in the uses clause, so if you have this:

uses
  Windows, JwaWinBase;

... it will call Jwa functions by default. However, if you cancel them:

uses
  JwaWinBase, Windows;

... it should call Windows functions by default, and you can predicate your Jwa functions as needed.

+8
source

, :

procedure Blah; inline;
begin
  Windows.Blah;
end;

procedure Blubb; inline;
begin
  JwaWinBase.Blubb;
end;

// later:
procedure UseThem;
begin
  Blah; // calls Windows.Blah
  Blubb; // calls JwaWinBase.Blubb
end;

( : -)).

+3

, , uses.

+2

, CodeRush (D7 ) Castalia D2009, , , , . Windows, jwaWinBase uses. jcpau jwaWinBase.CreateProcessAsUser, cpau CreateProcessAsUser Windows.CreateProcessAsUser . jwaWinBase .

Otherwise, I think it is a search and replacement in each case.

+2
source

All Articles