Bonjour,
DsoFile.dll permet de récupérer le thumbnail d'un document office si il existe, savez - vous comment transformer l'objet renvoyé par l'API en objet image en csharp ?
Bonjour,
DsoFile.dll permet de récupérer le thumbnail d'un document office si il existe, savez - vous comment transformer l'objet renvoyé par l'API en objet image en csharp ?
Quel est le type de l'objet renvoyé par cette API ?
Thomas LEBRUN: MCAD.NET, MCTS (Win et Web), MCPD(Win et Web) & Microsoft MVP Client Application Development
WPF par la pratique, mon livre sur WPF ! (également disponible ici ou là)
A la découverte de .NET
C'est un type System.__ComObject.
Hum.. alors là, ca se complique car pour caster un objet COM en Image, je vois pas trop comment faire![]()
Thomas LEBRUN: MCAD.NET, MCTS (Win et Web), MCPD(Win et Web) & Microsoft MVP Client Application Development
WPF par la pratique, mon livre sur WPF ! (également disponible ici ou là)
A la découverte de .NET
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 Public Shared Function IPictureDispToImage(ByVal picture As Object) As Image If (picture Is Nothing) Then Return Nothing End If Dim ptr1 As Integer = 0 Dim disp1 As stdole.IPictureDisp = CType(picture, stdole.IPictureDisp) Select Case disp1.Type Case -1 Return Nothing Case 0 Return Nothing Case 1 Return Image.FromHbitmap(New IntPtr(disp1.Handle), New IntPtr(disp1.hPal)) Case 2 Dim header1 As New System.Drawing.imaging.WmfPlaceableFileHeader header1.BboxRight = CType(disp1.Width, Short) header1.BboxBottom = CType(disp1.Height, Short) Return CType(New System.Drawing.imaging.Metafile(New IntPtr(disp1.Handle), header1, False).Clone, Image) Case 3 Return CType(System.Drawing.Icon.FromHandle(New IntPtr(disp1.Handle)).Clone, Image) Case 4 Return CType(New System.Drawing.imaging.Metafile(New IntPtr(disp1.Handle), False).Clone, Image) End Select Throw New ArgumentException("Image inconnue") End Function
Partager