顯示具有 Windows 標籤的文章。 顯示所有文章
顯示具有 Windows 標籤的文章。 顯示所有文章

2021年6月20日 星期日

Windows Task Scheduler 工作排程,程式中使用CreateOleObject操作Excel,出現錯誤訊息

Windows Task Scheduler 工作排程,程式中使用CreateOleObject操作Excel,出現錯誤訊息

Exception class name: 
  EOleException

Exception message: 
  The file name or path does not exist.
  The file is being used by another program.
  The workbook you are trying to save has the same name as a currently open workbook
  Microsoft Excel cannot access the file 'D:\xxxxxx'. There are several possible reasons:


手動建立資料夾
     for 64 bit Windows
  C:\Windows\SysWOW64\config\systemprofile\Desktop 

  for 32 bit Windows
  C:\Windows\System32\config\systemprofile\Desktop 


設定完成後再次登出,讓系統自動執行,接著出現以下錯誤訊息

Exception class name: 
  EOleSysError

Exception message: 
  The server process could not be started because the configured identity is incorrect. 
  Check the username and password, ProgID: "Excel.Application"

DCOM Config
  控制台 -> 系統管理工具  -> 元件服務 ,或是在命令提示字元輸入 dcomcnfg
  如果沒有看到Microsoft Excel Application選項,可以試著在命令提示字元裡操作
  MMC comexp.msc /32

後來試著在Security加入使用帳號

Identity 選用 The laumching user.



2018年7月15日 星期日

Delphi 取得桌面資料夾的路徑和取得我的文件的路徑

function GetShellFolders(strDir: string): string;
const
  regPath = '\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders';
var
  Reg: TRegistry;
  strFolders: string;
begin
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_CURRENT_USER;
    if Reg.OpenKey(regPath, false) then
    begin
      strFolders := Reg.ReadString(strDir);
    end;
  finally
    Reg.Free;
  end;
  result := strFolders;
end;

Ex:

{獲取桌面}
function GetDeskeptPath: string;
begin
  Result := GetShellFolders('Desktop'); //是取得桌面資料夾的路徑
end;

{獲取我的文件}
function GetMyDoumentpath: string;
begin
  Result := GetShellFolders('Personal'); //我的文件
end;

轉貼至: http://fecbob.pixnet.net/blog/post/38063575-delphi-取得桌面資料夾的路徑和取得我的文件

2018年3月21日 星期三

Runtime error 217 at 5015D5F4 (Windows 2016)

Delphi 編譯後的執行檔安裝到Windows2016中執行,出現 Runtime error 217 at xxxxxxxx

處理辦法:
  執行檔滑鼠右鍵 > 內容,使用Run compatibility troubleshooter功能可以排除狀況