May 29

域名格式为 abc.mycompany.com,如果只要abc这个短域名,方法比较简单:

C/C++ Code Copy Code To Clipboard
  1. function fGetDomainName: String;  
  2. var vlDomainName : array[0..30] of char;  
  3.     vlSize : ^DWORD;  
  4. begin  
  5.     New(vlSize);  
  6.     vlSize^ := 30;  
  7.     ExpandEnvironmentStrings(PChar('%USERDOMAIN%'), vlDomainName, vlSize^);  
  8.     Dispose(vlSize);  
  9.     Result := vlDomainName;  
  10. end;  

如果要完整域名,稍麻烦些:

C/C++ Code Copy Code To Clipboard
  1. //先定义输入类型,  
  2. type  
  3.     COMPUTER_NAME_FORMAT = (  
  4.     ComputerNameNetBIOS,  
  5.     ComputerNameDnsHostname,  
  6.     ComputerNameDnsDomain,  
  7.     ComputerNameDnsFullyQualified,  
  8.     ComputerNamePhysicalNetBIOS,  
  9.     ComputerNamePhysicalDnsHostname,  
  10.     ComputerNamePhysicalDnsDomain,  
  11.     ComputerNamePhysicalDnsFullyQualified,  
  12.     ComputerNameMax);  
  13.   
  14. //GetComputerNameEx这个函数可以根据上面的输入要求输出各种信息,但是要在此声明:  
  15. function GetComputerNameEx(NameType: COMPUTER_NAME_FORMAT; lpBuffer: LPSTR;  
  16.     var nSize: DWORD): BOOL; stdcall; external 'kernel32.dll' name 'GetComputerNameExA';  
  17.   
  18. //使用ComputerNameDnsDomain参数可以得到完整域名  
  19. function fGetDomainName: String;  
  20. var vlDomainName : array[0..30] of char;  
  21.     vlSize : ^DWORD;  
  22. begin  
  23.     New(vlSize);  
  24.     vlSize^ := 30;  
  25.     GetComputerNameEx(ComputerNameDnsDomain,vlDomainName, vlSize^);  
  26.     Dispose(vlSize);  
  27.     Result := vlDomainName;  
  28. end;  

 

 

Tags: ,
Feb 9

在windows 7 64位上新装了Delphi 6,编译AMSIM时一切正常,但是编译solids时,出错compiled with a different version of XXX。试着重新下载了最新的源文件,尝试rebuild all projects,都报同样的错。

后来发现,出错的文件是SOLIDS和PVTPRO共用的单元文件,该文件存放在PVTPRO的目录里,里面使用了{$IFDEF}预编译指令来对不同的项目使用了不同的代码,在SOLIDS进行编译时,因为找不到这几个文件的源文件,所以直接引用了DCU,而在PVTPRO中编译过的DCU文件与在SOLIDS应该使用的有所不同,就出现了compiled with a different version of XXX的错误。要解决这个问题,就要使不同的项目在编译时,都需要找到这几个源文件并重新编译。

解决方法:在SOLIDS的project options中,在Directory/Search path中把那几个源文件所在的目录加进去。再编译,通过。

Mar 31

刚完成了AMSIM,现在要进行solids的改良,原来SOLIDS一切正常,但是现在编译时突然报错"File not found: "inputUnit.dfm"",一共有6个这种错误. 这些错误在做语法检查时不会出现,在编译时,COMPILING也没错,一到LINKING就报错.

奇怪的是,这6个xxx.dfm都是AMSIM中的文件,和solids完全没有关系.

编译虽然出错,但是SOLIDS.EXE文件却可以生成.生成的EXE文件运行起来有问题,想要DEBUG,却因为有这6个DFM找不到的错而不能进行.

再打开HYDRATE,编译一样出现这个错误,说找不到这6个DFM文件.

这3个项目有一些公用的模块,但不是这6个DFM.

在出错的2个项目目录中搜索这6个DFM的文件名,但都找不到.
 

把这6个DFM文件复制到SOLIDS目录下,编译就能通过.

通过以后再进行DEBUG,发现在CREATE WELCOMEFORM时有错,进入DPR文件一看,原来WELCOMEFORM的路径不对...应该是JACK在更新OMNIWORKS时把以前废弃的DPR文件给传上去了...改成正确的目录后,编译通过.再把原来复制进来的6个DFM文件删除,再编译也通过了...

一切恢复原样.

Tags: , , , , ,
Mar 14
Copy Code To Clipboard
  1. { Getting the Windows Directory }    
  2.   
  3. function GetWinDir: string;    
  4. var    
  5.   dir: array [0..MAX_PATH] of Char;    
  6. begin    
  7.   GetWindowsDirectory(dir, MAX_PATH);    
  8.   Result := StrPas(dir);    
  9. end;    
  10.   
  11. function WindowsDirectory: string;    
  12. var    
  13.   WinDir: PChar;    
  14. begin    
  15.   WinDir := StrAlloc(MAX_PATH);    
  16.   GetWindowsDirectory(WinDir, MAX_PATH);    
  17.   Result := string(WinDir);    
  18.   if Result[Length(Result)] <> '\' then    
  19.     Result := Result + '\';    
  20.   StrDispose(WinDir);    
  21. end;    
  22.   
  23. function GetWindowsDirectory(var S: String): Boolean;    
  24. var    
  25.   Len: Integer;    
  26. begin    
  27.   Len := Windows.GetWindowsDirectory(nil, 0);    
  28.   if Len > 0 then    
  29.   begin    
  30.     SetLength(S, Len);    
  31.     Len := Windows.GetWindowsDirectory(PChar(S), Len);    
  32.     SetLength(S, Len);    
  33.     Result := Len > 0;    
  34.   end else    
  35.     Result := False;    
  36. end;    
  37. { Getting the System Directory }    
  38.   
  39. function SystemDir: string;    
  40. var    
  41.   dir: array [0..MAX_PATH] of Char;    
  42. begin    
  43.   GetSystemDirectory(dir, MAX_PATH);    
  44.   Result := StrPas(dir);    
  45. end;    
  46.   
  47. function SystemDirectory: string;    
  48. var    
  49.   SysDir: PChar;    
  50. begin    
  51.   SysDir := StrAlloc(MAX_PATH);    
  52.   GetSystemDirectory(SysDir, MAX_PATH);    
  53.   Result := string(SysDir);    
  54.   if Result[Length(Result)] <> '\' then    
  55.     Result := Result + '\';    
  56.   StrDispose(SysDir);    
  57. end;    
  58.   
  59. function GetSystemDirectory(var S: String): Boolean;    
  60. var    
  61.   Len: Integer;    
  62. begin    
  63.   Len := Windows.GetSystemDirectory(nil, 0);    
  64.   if Len > 0 then    
  65.   begin    
  66.     SetLength(S, Len);    
  67.     Len := Windows.GetSystemDirectory(PChar(S), Len);    
  68.     SetLength(S, Len);    
  69.     Result := Len > 0;    
  70.   end else    
  71.     Result := False;    
  72. end;    
  73. { Getting the Temporary Directory }    
  74.   
  75. function GetTempDir: string;    
  76. var    
  77.   Buffer: array[0..MAX_PATH] of Char;    
  78. begin    
  79.   GetTempPath(SizeOf(Buffer) - 1, Buffer);    
  80.   Result := StrPas(Buffer);    
  81. end;    
  82.   
  83. function GetTempPath: string;    
  84. var    
  85.   TmpDir: PChar;    
  86. begin    
  87.   TmpDir := StrAlloc(MAX_PATH);    
  88.   GetTempPath(TmpDir, MAX_PATH);    
  89.   Result := string(TmpDir);    
  90.   if Result[Length(Result)] <> '\' then    
  91.     Result := Result + '\';    
  92.   StrDispose(TmpDir);    
  93. end;    
  94.   
  95. function GetTempPath(var S: String): Boolean;    
  96. var    
  97.   Len: Integer;    
  98. begin    
  99.   Len := Windows.GetTempPath(0, nil);    
  100.   if Len > 0 then    
  101.   begin    
  102.     SetLength(S, Len);    
  103.     Len := Windows.GetTempPath(Len, PChar(S));    
  104.     SetLength(S, Len);    
  105.     Result := Len > 0;    
  106.   end else    
  107.     Result := False;    
  108. end;    
  109.   
  110. procedure TForm1.Button1Click(Sender: TObject);    
  111. begin    
  112.   label1.Caption := GetWinDir;    
  113.   label2.Caption := GetSysDir;    
  114.   label3.Caption := GetTempDir;    
  115. end;   

 

Tags: , , ,
Jan 28

基准日期: 12/30/1899

Tags: ,
分页: 1/3 第一页 1 2 3 下页 最后页 [ 显示模式: 摘要 | 列表 ]