Total Commander Forum Index Total Commander
Форум поддержки пользователей Total Commander
Сайты: Все о Total Commander | Totalcmd.net | Ghisler.com | RU.TCKB
 
 RulesRules   SearchSearch   FAQFAQ   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Single Post  Topic: Autorun 
Author Message
Orion9



PostPosted: Mon Mar 03, 2025 18:15    Post subject: Reply with quote

Loopback
Всё заработало влёт, я аж офигел ) Спасибо!
Code:
Pragma AutorunPluginFields "CharSet:::CharDetect"

Func CharDetect(FileName, FieldIndex, UnitIndex)
    Static sLib = "uchardet" & (auX64 ? "" : "_x86") & ".dll", _
           hLib = DllCall("LoadLibrary", "wstr", COMMANDER_PATH & "\Ini\Tools\Libs\" & sLib, "ptr")
           
    If hLib = 0 Then Return "#Error# LoadLibrary " & sLib
   
    Static hUC = DllCall(sLib & '\uchardet_new', 'ptr:cdecl')
    If hUC = 0 Then Return "#Error# uchardet_new returned 0"
   
    DllCall(sLib & '\uchardet_reset', 'ptr', hUC, 'cdecl')
    ProcessExecGetOutput buf %COMSPEC% '/c type "%FileName%"'     
   
    Local size = StrLen(buf)
    Local Res = DllCall(sLib & '\uchardet_handle_data', 'ptr', hUC, 'str', buf, 'uint', size, 'int:cdecl')
    If Res > 0 Then Return "#Error# uchardet_handle_data returned " & Res

    DllCall(sLib & '\uchardet_data_end', 'ptr', hUC, 'cdecl')   
    Return DllCall(sLib & '\uchardet_get_charset', 'ptr', hUC, 'str:cdecl')
    #DllCall('uchardet\uchardet_delete', 'ptr', hUC, 'cdecl')
EndFunc

Знаю, что ProcessExecGetOutput для этих дел не годится, но это только эксперимент. Надеюсь, в будущем у Autorun найдутся свои функции для открытия файлов на чтение Very Happy А пока можно через консольную утилиту гнать:
https://github.com/gentlehill/uchardet?tab=readme-ov-file
и код совсем простой:
Code:
Func EncDetect(FileName, FieldIndex, UnitIndex)
    Local pipe, exe_tool = COMMANDER_PATH & "\Ini\Tools\uchardet.exe"
    ProcessExecGetOutput pipe %exe_tool% '"%FileName%"'   
    Return pipe
EndFunc

И большое спасибо за имена функций в GetState. Теперь выглядит как надо:
Code:
Thread #1:
    Origin: Main
    ThreadID: 3388
    Started: 03.03.2025 16:47:52

Thread #2:
    Origin: RunThread
    Function: ThreadTitle
    ThreadID: 4704
    Started: 03.03.2025 16:47:53

Thread #3:
    Origin: RunThread
    Function: ThreadNewsbar
    ThreadID: 3404
    Started: 03.03.2025 16:47:53

Thread #4:
    Origin: RunThread
    Function: ThreadSounds
    ThreadID: 1536
    Started: 03.03.2025 16:47:53

Это далеко не всё. Ещё позже отпишусь.

Добавлено спустя 4 минуты:

AkulaBig
Скорее всего вам придется, как и мне, избавляться от таких записей:
Code:
%"%SoftVideo%"

К сожалению, на ранних этапах использования Autorun я не разобрался с этой записью и допустил ошибку. Теперь приходится все исправлять.
View user's profile Send private message


Powered by phpBB © 2001, 2005 phpBB Group