Klaus
Nombre de messages : 12331 Age : 75 Localisation : Ile de France Date d'inscription : 29/12/2009
| Sujet: Génération de code pour appels DLL Dim 1 Aoû 2010 - 13:30 | |
| Comme mes DLL's se multiplient, et comme elles peuvent être appelées directement par dll_on ou dynamiquement à l'aide de ma DLL DynamicallyLoadDLL, les appels deviennent complexes. En tout cas, il n'est pas évident de se souvenir de tout. J'ai donc fait un petit "wizard", un générateur nommé GenCallDLL dans lequel on sélectionne la DLL ciblée, la routine que l'on veut appeler, le mode (directement ou par DynamicallyLoadDLL), puis on clique sur un bouton "Générer" et on voir apparaître une ou plusieures lignes Panoramic. Ces lignes peuvent êtgre copiées dans le presse-papier via un bouton "Copier dans le presse-papier". Avant de les copier, on peut les modifier dans le mémo affiché. L'idée, c'est de le compiler en GenCallDLL.exe et le lancer de sorte à l'avoir à l'écran en même temps que la fenêtre de l'éditeur ! Voici le source: - Code:
-
' ************************************************************************ ' * * ' * GenCallDLL - Générateur d'appels de fonctions DLL * ' * * ' ************************************************************************
label GUI, sel_DLL, sel_funct, ini_KGF, ini_IPC, ini_Dyn, ini_Prog, ini_Str label generer, copier, gen_dyn, gen_std, gen_dyn_commun label gen_dyn_KGF, gen_dyn_IPC, gen_dyn_Dyn, gen_dyn_Prog, gen_dyn_Str label gen_std_KGF, gen_std_IPC, gen_std_Dyn, gen_std_Prog, gen_std_Str
dim dll_index%, dll_nom$, funct_index%, funct_nom$ dim n%, i%, a$ a$ = chr$(34)
gosub GUI : ' créer l'interface visuel
end
' création de l'interface visuel GUI: Caption 0,"Génération d'appels de fonctions DLL" check 10 : top 10,10 : left 10,10 : width 10,150 : caption 10,"Utiliser DynamicallyCallDLL" alpha 20 : top 20,40 : left 20,10 : caption 20,"DLL Ciblée:" combo 21 : top 21,60 : left 21,10 : width 21,150 item_add 21,"KGF.dll" item_add 21,"IPC.dll" item_add 21,"DynamicallyLoadDLL" item_add 21,"LoadProgram.dll" item_add 21,"Strings.dll" on_change 21,sel_DLL alpha 30 : top 30,40 : left 30,200 : caption 30,"Fonction de la DLL:" combo 31 : top 31,60 : left 31,200 : width 31,200 button 40 : top 40,90 : left 40,10 : width 40,550 : caption 40,"Générer..." : on_click 40,generer font_bold 40 memo 41 : top 41,130 : left 41,10 : width 41,550 button 50 : top 50,230 : left 50,10 : width 50,550 : caption 50,"Copier dans presse-papier" : on_click 50,copier
return
' sélection d'une DLL sel_DLL: dll_nom$ = text$(21) dll_index% = item_index(21) off_change 31 clear 31 select dll_index% case 1: gosub ini_KGF case 2: gosub ini_IPC case 3: gosub ini_Dyn case 4: gosub ini_Prog case 5: gosub ini_Str end_select on_change 31,sel_funct return
' sélection d'une fonction sel_funct: funct_nom$ = text$(31) funct_index% = item_index(31) return ini_KGF: item_add 31,"PrinterManager" item_add 31,"PrinterFunction" item_add 31,"ClipboardCopy" item_add 31,"SelectWindowsPrinter" item_add 31,"GetPrinterCount" item_add 31,"bin_ROL" item_add 31,"bin_ROR" item_add 31,"bin_SHL" item_add 31,"bin_SHR" item_add 31,"bin_WROL" item_add 31,"bin_WROR" item_add 31,"bin_WSHL" item_add 31,"bin_WSHR" item_add 31,"bin_BROL" item_add 31,"bin_BROR" item_add 31,"bin_BSHL" item_add 31,"bin_BSHR" item_add 31,"IPCGetHandle" item_add 31,"IPCSendMessage" item_add 31,"FolderSelect" item_add 31,"FileOpen" item_add 31,"FileCreate" item_add 31,"WindowTopMost" item_add 31,"KGFdllVersion" item_add 31,"WindowEllipticHole" item_add 31,"WindowRectangleHole" item_add 31,"WindowAddEllipticRegion" item_add 31,"WindowAddRectangleRegion" item_add 31,"WindowRegionHole" item_add 31,"WindowRegionAsWindow" item_add 31,"WindowGetWindowRegion" item_add 31,"RandomValue" item_add 31,"ValueListEditor" item_add 31,"MaskEdit" return ini_IPC: item_add 31,"IPCGetHandle" item_add 31,"IPCSendMessage" return ini_Dyn: item_add 31,"LoadDLL" item_add 31,"UnLoadDLL" item_add 31,"TargetDLL" item_add 31,"CallDLL0" item_add 31,"CallDLL1" item_add 31,"CallDLL2" item_add 31,"CallDLL3" item_add 31,"CallDLL4" item_add 31,"CallDLL5" item_add 31,"CallDLL6" return ini_Prog: item_add 31,"LoadProgramMinimized" item_add 31,"KillProcessByHandle" return ini_Str: item_add 31,"CompareStr" return ' generer le code generer: if dll_index%=0 i% = message_error_ok("Il faut sélectionner une DLL !") return end_if if funct_index%=0 i% = message_error_ok("Il faut sélectionner une fonction !") return end_if clear 41 if checked(10)=1 gosub gen_dyn else gosub gen_std end_if return ' générer lo code avec DynamicallyLoadedDLL gen_dyn: select DLL_index% case 1: gosub gen_dyn_KGF case 2: gosub gen_dyn_IPC case 3: gosub gen_dyn_Dyn case 4: gosub gen_dyn_Prog case 5: gosub gen_dyn_Str end_select return ' générer lr code standard gen_std: select DLL_index% case 1: gosub gen_std_KGF case 2: gosub gen_std_IPC case 3: gosub gen_std_Dyn case 4: gosub gen_std_Prog case 5: gosub gen_std_Str end_select return
' copier dans presse-papier copier: n% = 0 for i%=1 to count(41) n% = n% + len(item_read$(41,i%)) + 2 next i% select_text 41,1,n% clipboard_copy 41 return
gen_dyn_KGF: gosub gen_dyn_commun select funct_index% case 1: item_add 41,"res% = dll_call4( "+a$+"CallDLL4"+a$+" , f% , phnd% , chnd% ,opt% )" case 2: item_add 41,"res% = dll_call6( "+a$+"CallDLL6"+a$+" , f% , phnd% , chnd% , opt1% , opt2% , opt3% )" case 3: item_add 41,"res% = dll_call1( "+a$+"CallDLL1"+a$+" , hnd% )" case 4: item_add 41,"res% = dll_call2( "+a$+"CallDLL2"+a$+" , adr(nom$) , len(nom$))" case 5: item_add 41,"res% = dll_call0( "+a$+"CallDLL0"+a$+" )" case 6: item_add 41,"res% = DLL_call2( "+a$+"CallDLL2"+a$+" , val% , n%)" case 7: item_add 41,"res% = DLL_call2( "+a$+"CallDLL2"+a$+" , val% , n%)" case 8: item_add 41,"res% = DLL_call2( "+a$+"CallDLL2"+a$+" , val% , n%)" case 9: item_add 41,"res% = DLL_call2( "+a$+"CallDLL2"+a$+" , val% , n%)" case 10: item_add 41,"res% = DLL_call2( "+a$+"CallDLL2"+a$+" , val% , n%)" case 11: item_add 41,"res% = DLL_call2( "+a$+"CallDLL2"+a$+" , val% , n%)" case 12: item_add 41,"res% = DLL_call2( "+a$+"CallDLL2"+a$+" , val% , n%)" case 13: item_add 41,"res% = DLL_call2( "+a$+"CallDLL2"+a$+" , val% , n%)" case 14: item_add 41,"res% = DLL_call2( "+a$+"CallDLL2"+a$+" , val% , n%)" case 15: item_add 41,"res% = DLL_call2( "+a$+"CallDLL2"+a$+" , val% , n%)" case 16: item_add 41,"res% = DLL_call2( "+a$+"CallDLL2"+a$+" , val% , n%)" case 17: item_add 41,"res% = DLL_call2( "+a$+"CallDLL2"+a$+" , val% , n%)" case 18: item_add 41,"handle_boite% = dll_call3( "+a$+"CallDLL3"+a$+" , adr(nom_prog_dest$) , len(nom_prog_dest$) , id_boite% )" case 19: item_add 41,"res% = dll_call3( "+a$+"CallDLL3"+a$+" , adr(mes$) , len(mes$) , handle_boite% )" case 20: item_add 41,"res% = DLL_call4( "+a$+"CallDLL4"+a$+" , adr(racine$) , adr(dossier$) , len(dossier$) , mode% )" case 21: item_add 41,"res% = DLL_call4( "+a$+"CallDLL4"+a$+" , adr(racine$) , adr(dossier$) , len(dossier$) , mode% )" case 22: item_add 41,"res% = DLL_call4( "+a$+"CallDLL4"+a$+" , adr(racine$) , adr(filtre$) , adr(fichier$) , len(fichier$) )" case 23: item_add 41,"res% = DLL_call2( "+a$+"CallDLL2"+a$+" , handle(numero_form) , flag% )" case 24: item_add 41,"res% = DLL_call1( "+a$+"CallDLL1"+a$+" , adr(vers$) )" case 25: item_add 41,"res% = DLL_call6( "+a$+"CallDLL6"+a$+" , handle(numero_form%) , mode% , top , left% , width% , height% )" case 26: item_add 41,"res% = DLL_call6( "+a$+"CallDLL6"+a$+" , handle(numero_form%) , mode% , top% , left% , width% , height% )" case 27: item_add 41,"res% = DLL_call5( "+a$+"CallDLL5"+a$+" , adr(region%) , top% , left% , width% , height% )" case 28: item_add 41,"res% = DLL_call5( "+a$+"CallDLL5"+a$+" , adr(region%) , top% , left% , width% , height% )" case 29: item_add 41,"res% = DLL_call3( "+a$+"CallDLL3"+a$+" , handle(numero_form%) , mode% , adr(region%) )" case 30: item_add 41,"res% = DLL_call2( "+a$+"CallDLL2"+a$+" , handle(numero_form%) , adr(region%) )" case 31: item_add 41,"res% = DLL_call2( "+a$+"CallDLL2"+a$+" , handle(numero_form%) , adr(region%) )" case 32: item_add 41,"res% = DLL_call1( "+a$+"CallDLL1"+a$+" , max%)" case 33: item_add 41,"res% = DLL_call6( "+a$+"CallDLL6"+a$+" , f% , obj% , p1% , p2% , p3% , p4%)" case 34: item_add 41,"res% = DLL_call6( "+a$+"CallDLL6"+a$+" , f% , obj% , p1% , p2% , p3% , p4% )" end_select return gen_dyn_IPC: gosub gen_dyn_commun select funct_index% case 1: item_add 41,"handle_boite% = dll_call3( "+a$+"CallDLL3"+a$+" , adr(nom_prog_dest$) , len(nom_prog_dest$) , id_boite% )" case 2: item_add 41,"res% = dll_call3( "+a$+"CallDLL3"+a$+" , adr(mes$) , len(mes$) , handle_boite% )" end_select return gen_dyn_Dyn: i% = message_error_ok("Cette DLL n'est pas disponible en chargement dynamique !") return gen_dyn_Prog: gosub gen_dyn_commun select funct_index% case 1: item_add 41,"res% = dll_call2( "+a$+"CallDLL2"+a$+" , code% , handle(numero_form%) )" case 2: item_add 41,"res% = dll_call1( "+a$+"CallDLL1"+a$+" , handle_programme% )" end_select return gen_dyn_Str: gosub gen_dyn_commun select funct_index% case 1: item_add 41,"res% = dll_call2( "+a$+"CallDLL2"+a$+" , adr(str1$) , adr(str2$) )" end_select return gen_dyn_commun: item_add 41,"' éventuellement charger la DLL:" item_add 41,"dll_handle% = dll_call1( "+a$+"LoadDLL"+a$+" , "+a$+dll_nom$+a$+" )" item_add 41,"' ..." item_add 41,"res% = dll_call2( "+a$+"TargetDLL"+a$+" , dll_handle% , "+a$+funct_nom$+a$+" )" return gen_std_KGF: select funct_index% case 1: item_add 41,"res% = dll_call4( "+a$+"PrinterManager"+a$+" , f% , phnd% , chnd% ,opt% )" case 2: item_add 41,"res% = dll_call6( "+a$+"PrinterFunction"+a$+" , f% , phnd% , chnd% , opt1% , opt2% , opt3% )" case 3: item_add 41,"res% = dll_call1( "+a$+"ClipboardCopy"+a$+" , hnd% )" case 4: item_add 41,"res% = dll_call2( "+a$+"SelectWindowsPrinter"+a$+" , adr(nom$) , len(nom$))" case 5: item_add 41,"res% = dll_call0( "+a$+"GetPrinterCount"+a$+" )" case 6: item_add 41,"res% = DLL_call2( "+a$+"bin_ROL"+a$+" , val% , n%)" case 7: item_add 41,"res% = DLL_call2( "+a$+"bin_ROR"+a$+" , val% , n%)" case 8: item_add 41,"res% = DLL_call2( "+a$+"bin_SHL"+a$+" , val% , n%)" case 9: item_add 41,"res% = DLL_call2( "+a$+"bin_SHR"+a$+" , val% , n%)" case 10: item_add 41,"res% = DLL_call2( "+a$+"bin_WROL"+a$+" , val% , n%)" case 11: item_add 41,"res% = DLL_call2( "+a$+"bin_WROR"+a$+" , val% , n%)" case 12: item_add 41,"res% = DLL_call2( "+a$+"bin_WSHL"+a$+" , val% , n%)" case 13: item_add 41,"res% = DLL_call2( "+a$+"bin_WSHR"+a$+" , val% , n%)" case 14: item_add 41,"res% = DLL_call2( "+a$+"bin_BROL"+a$+" , val% , n%)" case 15: item_add 41,"res% = DLL_call2( "+a$+"bin_BROR"+a$+" , val% , n%)" case 16: item_add 41,"res% = DLL_call2( "+a$+"bin_BSHL"+a$+" , val% , n%)" case 17: item_add 41,"res% = DLL_call2( "+a$+"bin_BSHR"+a$+" , val% , n%)" case 18: item_add 41,"handle_boite% = dll_call3( "+a$+"IPCGetHandle"+a$+" , adr(nom_prog_dest$) , len(nom_prog_dest$) , id_boite% )" case 19: item_add 41,"res% = dll_call3( "+a$+"IPSendMessage"+a$+" , adr(mes$) , len(mes$) , handle_boite% )" case 20: item_add 41,"res% = DLL_call4( "+a$+"FolderSelect"+a$+" , adr(racine$) , adr(dossier$) , len(dossier$) , mode% )" case 21: item_add 41,"res% = DLL_call4( "+a$+"FileOpen"+a$+" , adr(racine$) , adr(dossier$) , len(dossier$) , mode% )" case 22: item_add 41,"res% = DLL_call4( "+a$+"FileCreate"+a$+" , adr(racine$) , adr(filtre$) , adr(fichier$) , len(fichier$) )" case 23: item_add 41,"res% = DLL_call2( "+a$+"WindowTopMost"+a$+" , handle(numero_form) , flag% )" case 24: item_add 41,"res% = DLL_call1( "+a$+"KGFdllVersion"+a$+" , adr(vers$) )" case 25: item_add 41,"res% = DLL_call6( "+a$+"WindowEllipticHole"+a$+" , handle(numero_form%) , mode% , top , left% , width% , height% )" case 26: item_add 41,"res% = DLL_call6( "+a$+"WindowRectangleHole"+a$+" , handle(numero_form%) , mode% , top% , left% , width% , height% )" case 27: item_add 41,"res% = DLL_call5( "+a$+"WindowAddEllipticRegion"+a$+" , adr(region%) , top% , left% , width% , height% )" case 28: item_add 41,"res% = DLL_call5( "+a$+"WindowAddRectangleRegion"+a$+" , adr(region%) , top% , left% , width% , height% )" case 29: item_add 41,"res% = DLL_call3( "+a$+"WindowRegionHole"+a$+" , handle(numero_form%) , mode% , adr(region%) )" case 30: item_add 41,"res% = DLL_call2( "+a$+"WindowRegionAsWindow"+a$+" , handle(numero_form%) , adr(region%) )" case 31: item_add 41,"res% = DLL_call2( "+a$+"WindowGetWindowRegion"+a$+" , handle(numero_form%) , adr(region%) )" case 32: item_add 41,"res% = DLL_call1( "+a$+"RandomValue"+a$+" , max%)" case 33: item_add 41,"res% = DLL_call6( "+a$+"ValueListEditor"+a$+" , f% , obj% , p1% , p2% , p3% , p4%)" case 34: item_add 41,"res% = DLL_call6( "+a$+"MaskEdit"+a$+" , f% , obj% , p1% , p2% , p3% , p4% )" end_select return gen_std_IPC: select funct_index% case 1: item_add 41,"handle_boite% = dll_call3( "+a$+"IPCGetHandle"+a$+" , adr(nom_prog_dest$) , len(nom_prog_dest$) , id_boite% )" case 2: item_add 41,"res% = dll_call3( "+a$+"IPSendMessage"+a$+" , adr(mes$) , len(mes$) , handle_boite% )" end_select return gen_std_Dyn: item_add 41," !!!! ATTENTION ! Cette fonction ne doit être appelée que pour une DLL non gérée ici !" select funct_index% case 1: item_add 41,"res% = dll_call1( "+a$+"LoadDLL"+a$+" )" case 2: item_add 41,"res% = dll_call1( "+a$+"UnLoadDLL"+a$+" )" case 3: item_add 41,"res% = dll_call2( "+a$+"TargetDLL"+a$+" , " + a$+DLL_nom$+a$+" )" case 4: item_add 41,"res£ = dll_call0( "+a$+"CallDLL0"+a$+" )" case 5: item_add 41,"res£ = dll_call1( "+a$+"CallDLL1"+a$+" , p1% )" case 6: item_add 41,"res£ = dll_call2( "+a$+"CallDLL2"+a$+" , p1% , p2% )" case 7: item_add 41,"res£ = dll_call3( "+a$+"CallDLL3"+a$+" , p1% , p2% , p3% )" case 8: item_add 41,"res£ = dll_call4( "+a$+"CallDLL4"+a$+" , p1% , p2% , p3% , p4% )" case 9: item_add 41,"res£ = dll_call5( "+a$+"CallDLL5"+a$+" , p1% , p2% , p3% , p4% , p5% )" case 10: item_add 41,"res£ = dll_call6( "+a$+"CallDLL6"+a$+" , p1% , p2% , p3% , p4% , p5% , p6%)" end_select return gen_std_Prog: select funct_index% case 1: item_add 41,"res% = dll_call2( "+a$+"LoadProgramMinimized"+a$+" , code% , handle(numero_form%) )" case 2: item_add 41,"res% = dll_call1( "+a$+"KillProcessByHandle"+a$+" , handle_programme% )" end_select return gen_std_Str: select funct_index% case 1: item_add 41,"res% = dll_call2( "+a$+"CompareStr"+a$+" , adr(str1$) , adr(str2$) )" end_select return
| |
|