gowpd

package module
v0.0.0-...-677f32d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2022 License: MIT Imports: 9 Imported by: 0

README

go-wpd

GoDoc Go Report Card Build status

Window Portable Device binding for Go language.

Examples

Enumerate devices

gowpd.Initialize()

mng, err := gowpd.CreatePortableDeviceManager()
if err != nil {
    panic(err)
}

deviceIDs, err := mng.GetDevices()
if err != nil {
    panic(err)
}

for i, deviceID := range deviceIDs {
    friendlyName, err := mng.GetDeviceFriendlyName(deviceID)
    if err != nil {
        panic(err)
    }
    manufacturer, err := mng.GetDeviceManufacturer(deviceID)
    if err != nil {
        panic(err)
    }
    description, err := mng.GetDeviceDescription(deviceID)
    if err != nil {
        panic(err)
    }

    log.Printf("[%d]:\n", i)
    log.Printf("\tName:         %s\n", friendlyName)
    log.Printf("\tManufacturer: %s\n", manufacturer)
    log.Printf("\tDescription:  %s\n", description)

    gowpd.FreeDeviceID(deviceID)
}

gowpd.Uninitialize()

Documentation

Overview

This package provides WindowsPortableDevice API.

Example

IPortableDeviceManager

gowpd.Initialize()

pPortableDeviceManager, err := gowpd.CreatePortableDeviceManager()
if err != nil {
	panic(err)
}

deviceIDs, err := pPortableDeviceManager.GetDevices()

Warnings not solved

Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized

Warning: .drectve `/FAILIFMISMATCH:"_CRT_STDIO_ISO_WIDE_SPECIFIERS=0" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized

Warning: corrupt .drectve at end of def file

비주얼 스튜디오 에서 빌드시 추가되는 링크 옵션이라고 함. 말그대로 경고 이므로 무시해도 되는 듯 함.

Example (ContentEnumerate)
package main

import (
	"log"
)

func RecursiveEnumerate(parentObjectID string, content *IPortableDeviceContent) {
	enum, err := content.EnumObjects(parentObjectID)
	if err != nil {
		panic(err)
	}

	objectIDs := make([]string, 0)
	for {
		tmp, err := enum.Next(10)
		if err != nil {
			panic(err)
		}
		if len(tmp) == 0 {
			break
		}
		objectIDs = append(objectIDs, tmp...)
	}

	for _, objectID := range objectIDs {
		log.Println(objectID)
	}

	for _, objectID := range objectIDs {
		RecursiveEnumerate(objectID, content)
	}
}

func main() {
	Initialize()

	mng, err := CreatePortableDeviceManager()
	if err != nil {
		panic(err)
	}

	pClientInfo, err := CreatePortableDeviceValues()
	if err != nil {
		panic(err)
	}
	pClientInfo.SetStringValue(WPD_CLIENT_NAME, "libgowpd")
	pClientInfo.SetUnsignedIntegerValue(WPD_CLIENT_MAJOR_VERSION, 1)
	pClientInfo.SetUnsignedIntegerValue(WPD_CLIENT_MINOR_VERSION, 0)
	pClientInfo.SetUnsignedIntegerValue(WPD_CLIENT_REVISION, 2)

	deviceIDs, err := mng.GetDevices()
	if err != nil {
		panic(err)
	}

	for _, deviceID := range deviceIDs {
		device, err := CreatePortableDevice()
		if err != nil {
			panic(err)
		}

		err = device.Open(deviceID, pClientInfo)
		if err != nil {
			panic(err)
		}

		content, err := device.Content()
		if err != nil {
			panic(err)
		}

		RecursiveEnumerate(WPD_DEVICE_OBJECT_ID, content)

		FreeDeviceID(deviceID)
	}

	Uninitialize()
}
Output:

Example (DeleteFromDevice)
Initialize()

mng, err := CreatePortableDeviceManager()
if err != nil {
	panic(err)
}

devices, err := mng.GetDevices()
if err != nil {
	panic(err)
}

clientInfo, err := CreatePortableDeviceValues()
if err != nil {
	panic(err)
}
clientInfo.SetStringValue(WPD_CLIENT_NAME, "libgowpd")
clientInfo.SetUnsignedIntegerValue(WPD_CLIENT_MAJOR_VERSION, 1)
clientInfo.SetUnsignedIntegerValue(WPD_CLIENT_MINOR_VERSION, 0)
clientInfo.SetUnsignedIntegerValue(WPD_CLIENT_REVISION, 2)

// objectID which will be deleted from the device.
targetObjectID := "F:\\test.txt"

for _, id := range devices {
	portableDevice, err := CreatePortableDevice()
	if err != nil {
		panic(err)
	}

	err = portableDevice.Open(id, clientInfo)
	if err != nil {
		panic(err)
	}

	content, err := portableDevice.Content()
	if err != nil {
		panic(err)
	}

	pObjectsToDelete, err := CreatePortableDevicePropVariantCollection()

	pv := new(PropVariant)
	pv.Init()
	pv.Set(targetObjectID)
	err = pObjectsToDelete.Add(pv)
	if err != nil {
		panic(err)
	}
	results, err := content.Delete(PORTABLE_DEVICE_DELETE_NO_RECURSION, pObjectsToDelete)
	if err != nil {
		count, err := results.GetCount()
		if err != nil {
			panic(err)
		}
		log.Printf("Count: %d\n", count)
		result, err := results.GetAt(0)
		if err != nil {
			panic(err)
		}
		log.Printf("Type: %d\n", result.GetType())
		if result.GetType() == VT_ERROR {
			log.Printf("error: %#x\n", result.GetError())
		}

		panic(err)
	}

	pv.Clear()
	FreeDeviceID(id)
}

mng.Release()
Uninitialize()
Output:

Example (DeviceEnumerate)
Initialize()

mng, err := CreatePortableDeviceManager()
if err != nil {
	panic(err)
}

deviceIDs, err := mng.GetDevices()
if err != nil {
	panic(err)
}

for i, deviceID := range deviceIDs {
	friendlyName, err := mng.GetDeviceFriendlyName(deviceID)
	if err != nil {
		panic(err)
	}
	manufacturer, err := mng.GetDeviceManufacturer(deviceID)
	if err != nil {
		panic(err)
	}
	description, err := mng.GetDeviceDescription(deviceID)
	if err != nil {
		panic(err)
	}

	log.Printf("[%d]:\n", i)
	log.Printf("\tName:         %s\n", friendlyName)
	log.Printf("\tManufacturer: %s\n", manufacturer)
	log.Printf("\tDescription:  %s\n", description)

	FreeDeviceID(deviceID)
}

Uninitialize()
Output:

Example (TransferToDevice)
Initialize()

mng, err := CreatePortableDeviceManager()
if err != nil {
	panic(err)
}

deviceIDs, err := mng.GetDevices()
if err != nil {
	panic(err)
}

pClientInfo, err := CreatePortableDeviceValues()
if err != nil {
	panic(err)
}
pClientInfo.SetStringValue(WPD_CLIENT_NAME, "libgowpd")
pClientInfo.SetUnsignedIntegerValue(WPD_CLIENT_MAJOR_VERSION, 1)
pClientInfo.SetUnsignedIntegerValue(WPD_CLIENT_MINOR_VERSION, 0)
pClientInfo.SetUnsignedIntegerValue(WPD_CLIENT_REVISION, 2)

targetDeviceFriendlyName := "SANDISK "
// objectId where the file will be transferred under.
targetObjectID := "F:\\"

for _, id := range deviceIDs {
	friendlyName, err := mng.GetDeviceFriendlyName(id)
	if err != nil {
		panic(err)
	}

	if friendlyName != targetDeviceFriendlyName {
		FreeDeviceID(id)
		continue
	}

	pPortableDevice, err := CreatePortableDevice()
	if err != nil {
		panic(err)
	}

	// Establish a connection
	err = pPortableDevice.Open(id, pClientInfo)
	if err != nil {
		panic(err)
	}

	// path to selected file to transfer to device.
	filePath := "E:\\RedLaboratory\\Media\\Picture\\result.png"
	filePath = "E:\\test.md"

	// open file as IStream.
	pFileStream, err := SHCreateStreamOnFile(filePath, 0)
	if err != nil {
		panic(err)
	}

	// acquire properties needed to transfer file to device
	pObjectProperties, err := GetRequiredPropertiesForContentType(WPD_CONTENT_TYPE_IMAGE, targetObjectID, filePath, pFileStream)
	if err != nil {
		panic(err)
	}

	// get stream to device
	content, err := pPortableDevice.Content()
	if err != nil {
		panic(err)
	}
	pTempStream, cbTransferSize, err := content.CreateObjectWithPropertiesAndData(pObjectProperties)
	if err != nil {
		panic(err)
	}

	// convert pTempStream to PortableDeviceDataStream to use more method e.g newly created object id.
	_pFinalObjectDataStream, err := pTempStream.QueryInterface(IID_IPortableDeviceDataStream)
	if err != nil {
		panic(err)
	}
	pFinalObjectDataStream := (*IPortableDeviceDataStream)(_pFinalObjectDataStream)

	// copy data from pFileStream to pFinalObjectDataStream
	cbBytesWritten, err := StreamCopy((*IStream)(_pFinalObjectDataStream), pFileStream, cbTransferSize)
	if err != nil {
		panic(err)
	}
	// call commit method to notice device that transferring data is finished.
	err = pFinalObjectDataStream.Commit(0)
	if err != nil {
		panic(err)
	}

	newlyCreatedObjectID, err := pFinalObjectDataStream.GetObjectID()
	if err != nil {
		panic(err)
	}
	log.Printf("\"%s\" has been transferred to device successfully: %d\n", newlyCreatedObjectID, cbBytesWritten)

	// transferring is finished. release the deviceID.
	FreeDeviceID(id)
	// release device interface too.
	pPortableDevice.Release()
}

for _, id := range deviceIDs {
	FreeDeviceID(id)
}

Uninitialize()
Output:

Example (TransferToPC)
Initialize()

mng, err := CreatePortableDeviceManager()
if err != nil {
	panic(err)
}

deviceIDs, err := mng.GetDevices()
if err != nil {
	panic(err)
}

clientInfo, err := CreatePortableDeviceValues()
if err != nil {
	panic(err)
}
clientInfo.SetStringValue(WPD_CLIENT_NAME, "libgowpd")
clientInfo.SetUnsignedIntegerValue(WPD_CLIENT_MAJOR_VERSION, 1)
clientInfo.SetUnsignedIntegerValue(WPD_CLIENT_MINOR_VERSION, 0)
clientInfo.SetUnsignedIntegerValue(WPD_CLIENT_REVISION, 2)

// object ID which will be transferred to PC.
targetObjectID := "F:\\test.txt"
// location where file will be transferred into.
targetDestination := "E:\\test.txt"

for _, id := range deviceIDs {
	portableDevice, err := CreatePortableDevice()
	if err != nil {
		panic(err)
	}

	portableDevice.Open(id, clientInfo)

	content, err := portableDevice.Content()
	if err != nil {
		panic(err)
	}
	resources, err := content.Transfer()
	if err != nil {
		panic(err)
	}

	objectDataStream, optimalTransferSize, err := resources.GetStream(targetObjectID, WPD_RESOURCE_DEFAULT, STGM_READ)
	if err != nil {
		panic(err)
	}

	pFinalFileStream, err := SHCreateStreamOnFile(targetDestination, STGM_CREATE|STGM_WRITE)
	if err != nil {
		panic(err)
	}

	totalBytesWritten, err := StreamCopy(pFinalFileStream, objectDataStream, optimalTransferSize)
	if err != nil {
		panic(err)
	}

	err = pFinalFileStream.Commit(0)
	if err != nil {
		panic(err)
	}

	log.Printf("Total bytes written: %d\n", totalBytesWritten)

	FreeDeviceID(id)
	portableDevice.Release()
}

mng.Release()
Uninitialize()
Output:

Index

Examples

Constants

View Source
const (
	GENERIC_READ    = C.GENERIC_READ & 0xffffffff    // 0x80000000
	GENERIC_WRITE   = C.GENERIC_WRITE & 0xffffffff   // 0x40000000
	GENERIC_EXECUTE = C.GENERIC_EXECUTE & 0xffffffff // 0x20000000
	GENERIC_ALL     = C.GENERIC_ALL & 0xffffffff     // 0x10000000
)
View Source
const (
	STATFLAG_DEFAULT = C.STATFLAG_DEFAULT
	STATFLAG_NONAME  = C.STATFLAG_NONAME
	STATFLAG_NOOPEN  = C.STATFLAG_NOOPEN
)
View Source
const (
	STGM_READ   = C.STGM_READ
	STGM_CREATE = C.STGM_CREATE
	STGM_WRITE  = C.STGM_WRITE
)
View Source
const (
	PORTABLE_DEVICE_DELETE_NO_RECURSION uint32 = iota
	PORTABLE_DEVICE_DELETE_WITH_RECURSION
)
View Source
const (
	WPD_DEVICE_OBJECT_ID string = "DEVICE"
)

Variables

This section is empty.

Functions

func CoCreateInstance

func CoCreateInstance(clsid CLSID, iid IID) (unsafe.Pointer, error)

func FreeDeviceID

func FreeDeviceID(pnpDeviceID PnPDeviceID)

func GetRequiredPropertiesForAllContentTypes

func GetRequiredPropertiesForAllContentTypes(pObjectProperties *IPortableDeviceValues, parentObjectID, filePath string, pFileStream *IStream) error

Set necessary properties for all content type.

func GetRequiredPropertiesForContactContentTypes

func GetRequiredPropertiesForContactContentTypes(pObjectProperties *IPortableDeviceValues) error

Set properties for contact type.

func GetRequiredPropertiesForImageContentTypes

func GetRequiredPropertiesForImageContentTypes(pObjectProperties *IPortableDeviceValues) error

Set properties for image type.

func GetRequiredPropertiesForMusicContentTypes

func GetRequiredPropertiesForMusicContentTypes(pObjectProperties *IPortableDeviceValues) error

Set properties for music type.

func GetStringValue

func GetStringValue(pProperties *IPortableDeviceProperties, objectID string, key PropertyKey) (string, error)

Reads a string property from the IPortableDeviceProperties interface and returns it as string.

func Initialize

func Initialize() error

func PnpToByte

func PnpToByte(pnpid PnPDeviceID) []byte

func PnpToStr

func PnpToStr(pnpid PnPDeviceID) string

func PropTest

func PropTest()

func StreamCopy

func StreamCopy(pDestStream *IStream, pSourceStream *IStream, cbTransferSize uint32) (uint32, error)

Copy the data from pSourceStream to pDestStream. cbTransferSize is buffer size temporarily to store data.

func UTF16ToString

func UTF16ToString(s []uint16) string

func Unicode2UTF8

func Unicode2UTF8(buf []byte) string

func Uninitialize

func Uninitialize()

Types

type CLSCTX

type CLSCTX int

C.CLSCTX

const (
	CLSCTX_INPROC_SERVER CLSCTX = 1 << iota
	CLSCTX_INPROC_HANDLER
	CLSCTX_LOCAL_SERVER
	CLSCTX_INPROC_SERVER16
	CLSCTX_REMOTE_SERVER
	CLSCTX_INPROC_HANDLER16
	CLSCTX_RESERVED1
	CLSCTX_RESERVED2
	CLSCTX_RESERVED3
	CLSCTX_RESERVED4
	CLSCTX_NO_CODE_DOWNLOAD
	CLSCTX_RESERVED5
	CLSCTX_NO_CUSTOM_MARSHAL
	CLSCTX_ENABLE_CODE_DOWNLOAD
	CLSCTX_NO_FAILURE_LOG
	CLSCTX_DISABLE_AAA
	CLSCTX_ENABLE_AAA
	CLSCTX_FROM_DEFAULT_CONTEXT
	CLSCTX_ACTIVATE_32_BIT_SERVER
	CLSCTX_ACTIVATE_64_BIT_SERVER
	CLSCTX_ENABLE_CLOAKING
	CLSCTX_APPCONTAINER
	CLSCTX_ACTIVATE_AAA_AS_IU
	CLSCTX_PS_DLL
)

type CLSID

type CLSID int

C.CLSID

const (
	CLSID_PortableDevice CLSID = iota
	CLSID_PortableDeviceFTM
	CLSID_PortableDeviceManager
	CLSID_PortableDeviceKeyCollection
	CLSID_PortableDeviceValues
	CLSID_PortableDevicePropVariantCollection
)

type DWORD

type DWORD uint32

C.DWORD

type GUID

type GUID int

C.GUID

const (
	WPD_CONTENT_TYPE_FUNCTIONAL_OBJECT GUID = iota
	WPD_CONTENT_TYPE_FOLDER
	WPD_CONTENT_TYPE_IMAGE
	WPD_CONTENT_TYPE_DOCUMENT
	WPD_CONTENT_TYPE_CONTACT
	WPD_CONTENT_TYPE_CONTACT_GROUP
	WPD_CONTENT_TYPE_AUDIO
	WPD_CONTENT_TYPE_VIDEO
	WPD_CONTENT_TYPE_TELEVISION
	WPD_CONTENT_TYPE_PLAYLIST
	WPD_CONTENT_TYPE_MIXED_CONTENT_ALBUM
	WPD_CONTENT_TYPE_AUDIO_ALBUM
	WPD_CONTENT_TYPE_IMAGE_ALBUM
	WPD_CONTENT_TYPE_VIDEO_ALBUM
	WPD_CONTENT_TYPE_MEMO
	WPD_CONTENT_TYPE_EMAIL
	WPD_CONTENT_TYPE_APPOINTMENT
	WPD_CONTENT_TYPE_TASK
	WPD_CONTENT_TYPE_PROGRAM
	WPD_CONTENT_TYPE_GENERIC_FILE
	WPD_CONTENT_TYPE_CALENDAR
	WPD_CONTENT_TYPE_GENERIC_MESSAGE
	WPD_CONTENT_TYPE_NETWORK_ASSOCIATION
	WPD_CONTENT_TYPE_CERTIFICATE
	WPD_CONTENT_TYPE_WIRELESS_PROFILE
	WPD_CONTENT_TYPE_MEDIA_CAST
	WPD_CONTENT_TYPE_SECTION
	WPD_CONTENT_TYPE_UNSPECIFIED
	WPD_CONTENT_TYPE_ALL

	WPD_OBJECT_FORMAT_EXIF
	WPD_OBJECT_FORMAT_WMA
	WPD_OBJECT_FORMAT_VCARD2
)

type HRESULT

type HRESULT uint32

C.HRESULT

const (
	S_OK    HRESULT = C.S_OK & 0xffffffff    // 0x00000000
	S_FALSE HRESULT = C.S_FALSE & 0xffffffff // 0x00000001

	E_ABORT             HRESULT = C.E_ABORT & 0xffffffff             // 0x80004004
	E_ACCESSDENIED      HRESULT = C.E_ACCESSDENIED & 0xffffffff      // 0x80070005
	E_FAIL              HRESULT = C.E_FAIL & 0xffffffff              // 0x80004005
	E_HANDLE            HRESULT = C.E_HANDLE & 0xffffffff            // 0x80070006
	ERROR_NOT_SUPPORTED HRESULT = C.ERROR_NOT_SUPPORTED & 0xffffffff // 0x80070032
	E_INVALIDARG        HRESULT = C.E_INVALIDARG & 0xffffffff        // 0x80070057
	E_NOINTERFACE       HRESULT = C.E_NOINTERFACE & 0xffffffff       // 0x80004002
	E_NOTIMPL           HRESULT = C.E_NOTIMPL & 0xffffffff           // 0x80004001
	E_OUTOFMEMORY       HRESULT = C.E_OUTOFMEMORY & 0xffffffff       // 0x8007000E
	E_POINTER           HRESULT = C.E_POINTER & 0xffffffff           // 0x80004003
	E_UNEXPECTED        HRESULT = C.E_UNEXPECTED & 0xffffffff        // 0x8000FFFF

	CO_E_NOTINITIALIZED HRESULT = C.CO_E_NOTINITIALIZED & 0xffffffff // 0x800401f0

)

func (HRESULT) Error

func (hr HRESULT) Error() string

func (HRESULT) String

func (hr HRESULT) String() string

type IEnumPortableDeviceObjectIDs

type IEnumPortableDeviceObjectIDs C.IEnumPortableDeviceObjectIDs

func (*IEnumPortableDeviceObjectIDs) Next

func (pEnumObjectIDs *IEnumPortableDeviceObjectIDs) Next(cObjects uint32) ([]string, error)

cObjects: Number of objects to request on each NEXT

type IID

type IID int

C.IID

const (
	IID_IPortableDevice IID = iota
	IID_IPortableDeviceManager
	IID_IPortableDeviceKeyCollection
	IID_IPortableDeviceContent
	IID_IPortableDeviceProperties
	IID_IPortableDeviceValues
	IID_IPortableDeviceDataStream
	IID_IPortableDevicePropVariantCollection
)

type IPortableDevice

type IPortableDevice C.IPortableDevice

func CreatePortableDevice

func CreatePortableDevice() (*IPortableDevice, error)

func (*IPortableDevice) Close

func (pPortableDevice *IPortableDevice) Close() error

func (*IPortableDevice) Content

func (pPortableDevice *IPortableDevice) Content() (*IPortableDeviceContent, error)

func (*IPortableDevice) Open

func (pPortableDevice *IPortableDevice) Open(pnpDeviceID PnPDeviceID, pClientInfo *IPortableDeviceValues) error

func (*IPortableDevice) Release

func (pPortableDevice *IPortableDevice) Release() error

type IPortableDeviceCapabilities

type IPortableDeviceCapabilities C.IPortableDeviceCapabilities

type IPortableDeviceContent

type IPortableDeviceContent C.IPortableDeviceContent

func (*IPortableDeviceContent) CreateObjectWithPropertiesAndData

func (pPortableDeviceContent *IPortableDeviceContent) CreateObjectWithPropertiesAndData(pValues *IPortableDeviceValues) (*IStream, uint32, error)

TODO not finished

func (*IPortableDeviceContent) Delete

func (*IPortableDeviceContent) EnumObjects

func (pPortableDeviceContent *IPortableDeviceContent) EnumObjects(parentObjectID string) (*IEnumPortableDeviceObjectIDs, error)

TODO not finished parentObjectID: start from it.

func (*IPortableDeviceContent) Properties

func (pPortableDeviceContent *IPortableDeviceContent) Properties() (*IPortableDeviceProperties, error)

func (*IPortableDeviceContent) Transfer

func (pPortableDeviceContent *IPortableDeviceContent) Transfer() (*IPortableDeviceResources, error)

type IPortableDeviceDataStream

type IPortableDeviceDataStream C.IPortableDeviceDataStream

func (*IPortableDeviceDataStream) Commit

func (pPortableDeviceDataStream *IPortableDeviceDataStream) Commit(dataFlags uint32) error

func (*IPortableDeviceDataStream) GetObjectID

func (pPortableDeviceDataStream *IPortableDeviceDataStream) GetObjectID() (string, error)

type IPortableDeviceEventCallback

type IPortableDeviceEventCallback C.IPortableDeviceEventCallback

type IPortableDeviceKeyCollection

type IPortableDeviceKeyCollection C.IPortableDeviceKeyCollection

func CreatePortableDeviceKeyCollection

func CreatePortableDeviceKeyCollection() (*IPortableDeviceKeyCollection, error)

func (*IPortableDeviceKeyCollection) Add

func (pPortableDeviceKeyCollection *IPortableDeviceKeyCollection) Add(key PropertyKey) error

type IPortableDeviceManager

type IPortableDeviceManager C.IPortableDeviceManager

func CreatePortableDeviceManager

func CreatePortableDeviceManager() (*IPortableDeviceManager, error)

func (*IPortableDeviceManager) GetDeviceDescription

func (pPortableDeviceManager *IPortableDeviceManager) GetDeviceDescription(pnpDeviceID PnPDeviceID) (string, error)

func (*IPortableDeviceManager) GetDeviceFriendlyName

func (pPortableDeviceManager *IPortableDeviceManager) GetDeviceFriendlyName(pnpDeviceID PnPDeviceID) (string, error)

func (*IPortableDeviceManager) GetDeviceManufacturer

func (pPortableDeviceManager *IPortableDeviceManager) GetDeviceManufacturer(pnpDeviceID PnPDeviceID) (string, error)

func (*IPortableDeviceManager) GetDevices

func (pPortableDeviceManager *IPortableDeviceManager) GetDevices() ([]PnPDeviceID, error)

func (*IPortableDeviceManager) Release

func (pPortableDeviceManager *IPortableDeviceManager) Release()

type IPortableDevicePropVariantCollection

type IPortableDevicePropVariantCollection C.IPortableDevicePropVariantCollection

func CreatePortableDevicePropVariantCollection

func CreatePortableDevicePropVariantCollection() (*IPortableDevicePropVariantCollection, error)

func (*IPortableDevicePropVariantCollection) Add

func (pPortableDevicePropVariantCollection *IPortableDevicePropVariantCollection) Add(value *PropVariant) error

func (*IPortableDevicePropVariantCollection) GetAt

func (pPortableDevicePropVariantCollection *IPortableDevicePropVariantCollection) GetAt(index uint32) (*PropVariant, error)

func (*IPortableDevicePropVariantCollection) GetCount

func (pPortableDevicePropVariantCollection *IPortableDevicePropVariantCollection) GetCount() (uint32, error)

type IPortableDeviceProperties

type IPortableDeviceProperties C.IPortableDeviceProperties

func (*IPortableDeviceProperties) GetPropertyAttributes

func (pPortableDeviceProperties *IPortableDeviceProperties) GetPropertyAttributes(objectID string, key PropertyKey) (*IPortableDeviceValues, error)

func (*IPortableDeviceProperties) GetValues

func (pPortableDeviceProperties *IPortableDeviceProperties) GetValues(objectID string, keys *IPortableDeviceKeyCollection) (*IPortableDeviceValues, error)

func (*IPortableDeviceProperties) SetValues

func (pPortableDeviceProperties *IPortableDeviceProperties) SetValues(objectID string, pValues *IPortableDeviceValues) error

TODO not finished

type IPortableDeviceResources

type IPortableDeviceResources C.IPortableDeviceResources

func (*IPortableDeviceResources) GetStream

func (pPortableDeviceResources *IPortableDeviceResources) GetStream(objectID string, key PropertyKey, mode uint32) (*IStream, uint32, error)

type IPortableDeviceValues

type IPortableDeviceValues C.IPortableDeviceValues

func CreatePortableDeviceValues

func CreatePortableDeviceValues() (*IPortableDeviceValues, error)

func GetRequiredPropertiesForContentType

func GetRequiredPropertiesForContentType(contentType GUID, parentObjectID, filePath string, pFileStream *IStream) (*IPortableDeviceValues, error)

Return required properties for content type to transfer data. Properties which will be set necessarily are WPD_OBJECT_PARENT_ID, WPD_OBJECT_SIZE, WPD_OBJECT_ORIGINAL_FILE_NAME, WPD_OBJECT_NAME and properties which will be set optionally are WPD_OBJECT_CONTENT_TYPE, WPD_OBJECT_FORMAT.

func (*IPortableDeviceValues) GetBoolValue

func (pPortableDeviceValues *IPortableDeviceValues) GetBoolValue(key PropertyKey) (bool, error)

func (*IPortableDeviceValues) GetStringValue

func (pPortableDeviceValues *IPortableDeviceValues) GetStringValue(key PropertyKey) (string, error)

func (*IPortableDeviceValues) GetUnsignedIntegerValue

func (pPortableDeviceValues *IPortableDeviceValues) GetUnsignedIntegerValue(key PropertyKey) (uint32, error)

func (*IPortableDeviceValues) GetUnsignedLargeIntegerValue

func (pPortableDeviceValeus *IPortableDeviceValues) GetUnsignedLargeIntegerValue(key PropertyKey) (uint64, error)

func (*IPortableDeviceValues) QueryInterface

func (pPortableDeviceValues *IPortableDeviceValues) QueryInterface(iid IID) (unsafe.Pointer, error)

func (*IPortableDeviceValues) Release

func (pPortableDeviceValues *IPortableDeviceValues) Release() error

func (*IPortableDeviceValues) SetGuidValue

func (pPortableDeviceValues *IPortableDeviceValues) SetGuidValue(key PropertyKey, value GUID) error

func (*IPortableDeviceValues) SetStringValue

func (pPortableDeviceValues *IPortableDeviceValues) SetStringValue(key PropertyKey, value string) error

func (*IPortableDeviceValues) SetUnsignedIntegerValue

func (pPortableDeviceValues *IPortableDeviceValues) SetUnsignedIntegerValue(key PropertyKey, value uint32) error

func (*IPortableDeviceValues) SetUnsignedLargeIntegerValue

func (pPortableDeviceValeus *IPortableDeviceValues) SetUnsignedLargeIntegerValue(key PropertyKey, value uint64) error

type IPropertyStore

type IPropertyStore C.IPropertyStore

type ISequentialStream

type ISequentialStream C.ISequentialStream

func (*ISequentialStream) Read

func (pSequentialStream *ISequentialStream) Read(buffer []byte) (uint32, error)

func (*ISequentialStream) Write

func (pSequentialStream *ISequentialStream) Write(buffer []byte) (uint32, error)

type IStream

type IStream C.IStream

func SHCreateStreamOnFile

func SHCreateStreamOnFile(fileName string, mode uint32) (*IStream, error)

func (*IStream) Commit

func (pStream *IStream) Commit(dataFlag uint32) error

func (*IStream) QueryInterface

func (pStream *IStream) QueryInterface(iid IID) (unsafe.Pointer, error)

func (*IStream) Read

func (pStream *IStream) Read(buffer []byte) (uint32, error)

func (*IStream) Release

func (pStream *IStream) Release() error

func (*IStream) Stat

func (pStream *IStream) Stat(statFlags uint32) (*StatStg, error)

func (*IStream) Write

func (pStream *IStream) Write(buffer []byte) (uint32, error)

type IUnknown

type IUnknown C.IUnknown

func (*IUnknown) QueryInterface

func (pUnknown *IUnknown) QueryInterface(iid IID) (unsafe.Pointer, error)

type PnPDeviceID

type PnPDeviceID C.PnPDeviceID

*WCHAR

type PropVariant

type PropVariant C.PROPVARIANT

func (*PropVariant) Clear

func (prop *PropVariant) Clear()

func (*PropVariant) GetError

func (prop *PropVariant) GetError() uint32

func (*PropVariant) GetType

func (prop *PropVariant) GetType() VARTYPE

func (*PropVariant) Init

func (prop *PropVariant) Init()

func (*PropVariant) Set

func (prop *PropVariant) Set(value interface{}) error

type PropertyKey

type PropertyKey int

C.PROPERTYKEY

const (
	WPD_CLIENT_NAME PropertyKey = iota
	WPD_CLIENT_MAJOR_VERSION
	WPD_CLIENT_MINOR_VERSION
	WPD_CLIENT_REVISION
	WPD_CLIENT_SECURITY_QUALITY_OF_SERVICE
	WPD_CLIENT_DESIRED_ACCESS

	WPD_OBJECT_PARENT_ID
	WPD_OBJECT_NAME
	WPD_OBJECT_PERSISTENT_UNIQUE_ID
	WPD_OBJECT_FORMAT
	WPD_OBJECT_CONTENT_TYPE
	WPD_OBJECT_SIZE
	WPD_OBJECT_ORIGINAL_FILE_NAME

	WPD_PROPERTY_ATTRIBUTE_FORM
	WPD_PROPERTY_ATTRIBUTE_CAN_READ
	WPD_PROPERTY_ATTRIBUTE_CAN_WRITE
	WPD_PROPERTY_ATTRIBUTE_CAN_DELETE
	WPD_PROPERTY_ATTRIBUTE_DEFAULT_VALUE
	WPD_PROPERTY_ATTRIBUTE_FAST_PROPERTY
	WPD_PROPERTY_ATTRIBUTE_RANGE_MIN
	WPD_PROPERTY_ATTRIBUTE_RANGE_MAX
	WPD_PROPERTY_ATTRIBUTE_RANGE_STEP
	WPD_PROPERTY_ATTRIBUTE_ENUMERATION_ELEMENTS
	WPD_PROPERTY_ATTRIBUTE_REGULAR_EXPRESSION
	WPD_PROPERTY_ATTRIBUTE_MAX_SIZE

	WPD_RESOURCE_DEFAULT
)

type StatStg

type StatStg struct {
	// contains filtered or unexported fields
}

type ULONG

type ULONG uint32

unsigned long

type VARTYPE

type VARTYPE uint16

C.VARENUM

const (
	VT_EMPTY            VARTYPE = 0
	VT_NULL             VARTYPE = 1
	VT_I2               VARTYPE = 2
	VT_I4               VARTYPE = 3
	VT_R4               VARTYPE = 4
	VT_R8               VARTYPE = 5
	VT_CY               VARTYPE = 6
	VT_DATE             VARTYPE = 7
	VT_BSTR             VARTYPE = 8
	VT_DISPATCH         VARTYPE = 9
	VT_ERROR            VARTYPE = 10
	VT_BOOL             VARTYPE = 11
	VT_VARIANT          VARTYPE = 12
	VT_UNKNOWN          VARTYPE = 13
	VT_DECIMAL          VARTYPE = 14
	VT_I1               VARTYPE = 16
	VT_UI1              VARTYPE = 17
	VT_UI2              VARTYPE = 18
	VT_UI4              VARTYPE = 19
	VT_I8               VARTYPE = 20
	VT_UI8              VARTYPE = 21
	VT_INT              VARTYPE = 22
	VT_UINT             VARTYPE = 23
	VT_VOID             VARTYPE = 24
	VT_HRESULT          VARTYPE = 25
	VT_PTR              VARTYPE = 26
	VT_SAFEARRAY        VARTYPE = 27
	VT_CARRAY           VARTYPE = 28
	VT_USERDEFINED      VARTYPE = 29
	VT_LPSTR            VARTYPE = 30
	VT_LPWSTR           VARTYPE = 31
	VT_RECORD           VARTYPE = 36
	VT_INT_PTR          VARTYPE = 37
	VT_UINT_PTR         VARTYPE = 38
	VT_FILETIME         VARTYPE = 64
	VT_BLOB             VARTYPE = 65
	VT_STREAM           VARTYPE = 66
	VT_STORAGE          VARTYPE = 67
	VT_STREAMED_OBJECT  VARTYPE = 68
	VT_STORED_OBJECT    VARTYPE = 69
	VT_BLOB_OBJECT      VARTYPE = 70
	VT_CF               VARTYPE = 71
	VT_CLSID            VARTYPE = 72
	VT_VERSIONED_STREAM VARTYPE = 73
	VT_BSTR_BLOB        VARTYPE = 0xfff
	VT_VECTOR           VARTYPE = 0x1000
	VT_ARRAY            VARTYPE = 0x2000
	VT_BYREF            VARTYPE = 0x4000
	VT_RESERVED         VARTYPE = 0x8000
	VT_ILLEGAL          VARTYPE = 0xffff
	VT_ILLEGALMASKED    VARTYPE = 0xfff
	VT_TYPEMASK         VARTYPE = 0xfff
)

type WCHAR

type WCHAR uint16

C.WCHAR 16bit-encoded

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL