#1 Tue 31 July 2007 10:44
- ceucile
- Participant occasionnel
- Date d'inscription: 5 Dec 2006
- Messages: 48
Fermer une application avec MapBasic
Bonjour,
J'utilise MapBasic au sein de VBA Access pour ouvrir une application GPS. Cela donne :
map.Do ("Run application """ & nomGps & """ ")
Maintenant j'aimerai pouvoir la fermer de la même manière, mais je ne connais pas la commande mapbasic permettant de faire cela. Quelqu'un pourrait-il m'aider?
Merci d'avance
Ceucile
Hors ligne
#2 Tue 31 July 2007 13:47
- ChristopheV
- Membre
- Lieu: Ajaccio
- Date d'inscription: 7 Sep 2005
- Messages: 3224
- Site web
Re: Fermer une application avec MapBasic
Bonjour,
Une piste
set map= nothing
Je suppose qu'à partir de l'instant ou l'instance de l'objet map est supprimé les threads associes le sont aussi.
A+
Christophe
Christophe
L'avantage d'être une île c'est d'être une terre topologiquement close
Hors ligne
#3 Tue 31 July 2007 14:20
- ceucile
- Participant occasionnel
- Date d'inscription: 5 Dec 2006
- Messages: 48
Re: Fermer une application avec MapBasic
Oui effectivement ça marche. Mais comme je veux garder ma carte, je suis obligée de recréer une instance de map. Enfin ça ira comme ça, merci beaucoup DIANA2D.dev.
ceucile
Hors ligne
#4 Thu 02 August 2007 10:36
- ChristopheV
- Membre
- Lieu: Ajaccio
- Date d'inscription: 7 Sep 2005
- Messages: 3224
- Site web
Re: Fermer une application avec MapBasic
Bonjour,
Une autre solution qui permet de lancer une application en mode exclusif et qui bloque la suite tant qu'elle n'est pas terminée.
Il suffit de définir la ligne de commande du logiciel à lancer (votre appli GPS) et de la transmettre à la fonction ExecCmd
A+
Christophe
Code:
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwmilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
lpApplicationName As String, ByVal lpCommandLine As String, ByVal _
lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As String, _
lpStartupInfo As STARTUPINFO, lpProcessInformation As _
PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, lpExitCode As Long) As Long
Private Function ExecCmd(cmdline$)
Dim Ret&
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
' Initialize the STARTUPINFO structure:
start.cb = Len(start)
' Start the shelled application:
Ret& = CreateProcessA(vbNullString, cmdline$, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, vbNullString, start, proc)
' Wait for the shelled application to finish:
Ret& = WaitForSingleObject(proc.hProcess, INFINITE)
Call GetExitCodeProcess(proc.hProcess, Ret&)
Call CloseHandle(proc.hThread)
Call CloseHandle(proc.hProcess)
ExecCmd = Ret&
End FunctionChristophe
L'avantage d'être une île c'est d'être une terre topologiquement close
Hors ligne


