出现的问题:
在编译delphi程序时出现提示为:
[Error] MyUnit.pas(LL): Undeclared identifier: 'NNNN'
其中:
MyUnit.pas 源文件的名称.
LL 第几行.
NNNN 提示的标识名.
原因:
编译器不能识别'NNN'这个标识。这可能是拼写错误或找不到定义文件造成。
 
解决方法:
  • 常见的错误是由于拼写错误造成,例子如下:
         var number: Integer;
         begin
        numbr := 1;
       变量定义为number,但使用时写成了numbr,将变量改正就可以。
  • 另一种是代码正确,但要用到的单元没有包含进去。如:
       try
        .
        .
        except
      on E: Exception do
     .
     [Error] Undeclared identifier: 'Exception'
      
     代码是正确,但没有包含“sysutils”。下面的表格列举了一些类型和函数用到的单元。
Type Unit
_Stream ADODB_TLB
akTop, akLeft, akRight, akBottom Controls
Application (the variable not a type) Forms
Beep SysUtils or Windows (different functions)
CGID_EXPLORER ShlObj
CN_BASE Controls
CoInitialize ActiveX
CopyFile Windows
CoUnInitialize ActiveX
CreateComObject ComObj
CreateOleObject ComObj
Date SysUtils
DeleteFile SysUtils or Windows (different versions)
DispatchInvokeError ComObj
DWORD Windows
EDatabaseError DB
EncodeDateTime DateUtils
EnumWindows Windows
EOleError ComObj
EOleException ComObj
EOleSysError ComObj
Exception SysUtils
ExtractFileName SysUtils
FileExists SysUtils
FileOpen SysUtils
FILETIME Windows
FindFirst SysUtils
FindFirstFile Windows
FindWindow Windows
FlushFileBuffers Windows
fmOpenRead SysUtils
fmShareDenyWrite SysUtils
Format SysUtils
FormatDateTime SysUtils
FreeAndNil SysUtils
fsBold Graphics
ftWideString DB
ftString DB
GetCurrentProcessId Windows
GetEnvironmentVariable SysUtils or Windows (different versions)
GetFileAttributes Windows
GetFileVersionInfoSize Windows
GetWindowLong Windows
GetStdHandle Windows
HDC Windows
HFont Windows
HINTERNET WinInet
HKEY_CURRENT_USER Windows
IHTMLDocument2 MSHTML or MSHTML_TLB
IHTMLElement MSHTML or MSHTML_TLB
IHTMLEventObj MSHTML or MSHTML_TLB
IID_IWebBrowser2 SHDocVw or SHDocVw_TLB
IMessage CDO_TLB
InternetClosehandle WinInet
InternetOpenUrl WinInet
InternetReadFile WinInet
IntToHex SysUtils
IntToStr SysUtils
IOleCommandTarget ActiveX
IOleContainer ActiveX
IPersistStreamInit ActiveX
IsSameDay DateUtils
IStream ActiveX
IWebBrowser2 SHDocVw or SHDocVw_TLB
LockWindowUpdate Windows
Log10 Math
LowerCase SysUtils
LPSTR Windows
MAX_PATH Windows
MessageBox Windows
MessageDlg Dialogs
MB_YESNO, MB_OK etc Windows
MinutesBetween DateUtils
Now SysUtils
OleInitialize ActiveX
OleUninitialize ActiveX
PItemIDList ShlObj
POleCmd ActiveX
POleCmdText ActiveX
PostMessage Windows
PosX StrUtils
QueryHighPerformanceCounter Windows
QueryPerformanceCounter Windows
ReverseString StrUtils
RoundTo Math
SendMessage Windows
SetForegroundWindow Windows
ShellExecute ShellAPI
ShellExecuteEx ShellAPI
SHGetFileInfo ShellAPI
SHFILEINFO ShellAPI
ShowMessage Dialogs
Sleep SysUtils
StrAlloc SysUtils
StrPas SysUtils
StrToDate SysUtils
StrToInt SysUtils
StrToIntDef SysUtils
TAdoConnection ADODB
TAdoQuery ADODB
TAlign Controls
TAlignment Classes
TAnchors Controls
TBitmap Graphics
TBlobStream DBTables
TCanvas Graphics
TClientSocket ScktComp
TComboBox StdCtrls
TComponent Classes
TControl Controls or QControls
TCriticalSection SyncObjs
TField DB
TFieldType DB
TFileName SysUtils
TFileStream Classes
TForm Forms
TFrame Forms
TGroupBox StdCtrls
TIID ActiveX
TIniFile IniFiles
TJPEGImage Jpeg
TLabel StdCtrls
TList Classes
TMemo StdCtrls
TMemoryStream Classes
TMouseButton Controls
TNofityEvent Classes
TObjectList Contnrs
TOSVersionInfo Windows
TPanel ExtCtrls
TPoint Types
TProcessEntry32 TlHelp32
TProgressBar ComCtrls or QComCtrls
TRadioButton StdCtrls
TRadioGroup ExtCtrls
TRect Types
TRegistry Registry
Trim SysUtils
TRoundToRange Math
TSearchRec SysUtils
TSize Windows
TSocketAddrIn Winsock
TStaticText StdCtrls
TStream Classes
TStringList Classes
TStrings Classes
TStringStream Classes
TSystemTime Windows
TTable DBTables
TTabSheet ComCtrls
TThread Classes
TTreeNode ComCtrls
TWebBrowser SHDocVw or SHDocVw_TLB
TWinSocketStream ScktComp
TWMCommand Messages
Unassigned Variants
VarArrayCreate Variants
VarArrayOf Variants
VirtualProtect Windows
WM_USER Messages
YearOf DateUtils