Bonjour,
Je cherche à réaliser une conversion d'heure UTC vers heure locale. La procédure que j'ai créée ci-dessous marche bien, mais j'ai le message d'erreur après
la conversion au moment du retour vers le programme appelant.
Où est mon erreur?erreur d'éxécution '49':
Convention d'appel de DLL incorrecte
* Merci *
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 Option Explicit Type SystemTime iYear As Integer iMonth As Integer iDayOfWeek As Integer iDay As Integer iHour As Integer iMinute As Integer iSecond As Integer iMilliseconds As Integer End Type Public Type TimeZoneInfo Bias As Long StandardName(31) As Integer StandardDate As Date StandardBias As Long DaylightName(31) As Integer DaylightDate As SystemTime DaylightBias As Long End Type Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TimeZoneInfo) As Long Declare Function SystemTimeToTzSpecificLocalTime Lib "kernel32" (lpTimeZoneInformation As TimeZoneInfo, lpUniversalTime As SystemTime, lpLocalTime As SystemTime) As Long ' Procedure de test ' ----------------- Public Sub Test_Utc2LocalTime() Dim testUTC As SystemTime Dim testLocal As SystemTime ' Initialiser Heure UTC avec heure actuelle pour tester testUTC.iYear = Year(Now) testUTC.iMonth = Month(Now) testUTC.iDay = Day(Now) testUTC.iHour = Hour(Now) testUTC.iMinute = Minute(Now) testUTC.iSecond = Second(Now) Call Utc2LocalTime(testUTC, testLocal) End Sub ' procédure de conversion ' ----------------------- Public Sub Utc2LocalTime(ByRef stUTC As SystemTime, ByRef stLocal As SystemTime) Dim iStatus As Integer Dim tziZoneInfo As TimeZoneInfo iStatus = GetTimeZoneInformation(tziZoneInfo) iStatus = SystemTimeToTzSpecificLocalTime(tziZoneInfo, stUTC, stLocal) ' En pas a pas (mode débug) , jusqu'ici tout va bien, l'heure UTC est bien convertie dans la variable stLocal (2 heures de plus) ' donc l'appel de la DLL est sans doute correct ' le message d'erreur apparait ensuite, après l'éxécution de "end sub", au retour vers le programme appelant. End Sub
Partager