Ver Mensaje Individual
  #3  
Antiguo 24-08-2006
harpo harpo is offline
Miembro
 
Registrado: jul 2006
Posts: 35
Reputación: 0
harpo Va por buen camino
Muchas gracias, funciona perfectamente

Ahora el código me queda así:
Código:
procedure CreateDevice (StillImage:IStillImage);
var
  hr: HRESULT;
  dwItemsReturned:Pointer;
  pBuffer:PSTI_DEVICE_INFORMATION_ARRAY;
  DeviceInformation:STI_DEVICE_INFORMATION;
  dwType:LongWord;
  dwFlags:LongWord;
  pDevice:IStiDevice;    //IStiDevice
  DeviceName:PWideChar;
  DeviceInternalName:string;
  i:integer;
begin
  CoInitialize(nil);
  hr := CoCreateInstance(CLSID_Sti, nil, CLSCTX_INPROC_SERVER, IID_IStillImage,stillImage);
  if Succeeded(hr) and Assigned(stillImage) then
  begin
    StillImage.Initialize(STI_VERSION,STI_DEVICE_CREATE_BOTH);
    hr:=StillImage.GetDeviceList(dwType,dwFlags,dwItemsReturned,pBuffer);
    for i:=0 to 1 do
    begin
         if pBuffer^[i].DeviceType = 131072 then
            DeviceInformation:=pBuffer^[i];
    end;
    for i:=0 to STI_MAX_INTERNAL_NAME_LENGTH do
    begin
        if DeviceInformation.szDeviceInternalName[i] <> '' then
             DeviceInternalName:=DeviceInternalName+STI_DEVICE_INFORMATION(pBuffer^).szDeviceInternalName[i];
    end;
   DeviceName:=StringToWideChar(DeviceInternalName,DeviceName,Length(DeviceInternalName));
   hr:=StillImage.CreateDevice(DeviceName,STI_DEVICE_CREATE_DATA,pDevice,nil);
   StillImage:=nil;
  end;
  CoUninitialize;

end;
El problema está en la función CreateDevice, creo q probablemente en el nombre que le estoy pasando. La cabecera en el sti.pas viene así:

Código:
 function CreateDevice(pwszDeviceName: PWideChar; dwMode: DWORD; out pDevice: IStiDevice; punkOuter: IUnknown): HRESULT; stdcall;
Y en la referencia de msdn viene lo siguiente:

Cita:
IStillImage::CreateDevice

The IStillImage::CreateDevice method creates an instance of the COM object that defines the IStiDevice COM Interface, and returns a pointer to the interface.
HRESULT
CreateDevice(
LPWSTRpwszDeviceName,
DWORDdwMode,
PSTIDEVICE*pDevice,
LPUNKNOWNpunkOuter
);

Parameters

pwszDeviceNameCaller-supplied pointer to a string representing an internal device name, obtained by calling IStillImage::GetSTILaunchInformation or IStillImage::GetDeviceList.

dwMode
Caller-supplied constant value indicating the Transfer Modes in which the device is to be used. The following values are valid. Mode Description
STI_DEVICE_CREATE_BOTH The device is being opened for both obtaining status and transferring data.
STI_DEVICE_CREATE_DATA The device is being opened only for data transfers.
STI_DEVICE_CREATE_STATUS The device is being opened only for obtaining status information.

pDeviceReceives a pointer to the IStiDevice COM Interface.

punkOuterOptional, caller-supplied pointer to the "controlling unknown" for object aggregation. See the following Comments section. Return Value

If the operation succeeds, the method returns S_OK. Otherwise, it returns one of the STIERR-prefixed error codes defined in stierr.h.
Headers

Declared in sti.h. Include sti.h.
Comments

For an application to use the IStiDevice interface, it must first call IStillImage::StiCreateInstance to get a pointer to the IStillImage interface, then call IStillImage::CreateDevice to get a pointer to the IStiDevice interface. The pointer received in pDevice is used subsequently when calling IStiDevice methods, as illustrated in the sample still image code, to obtain access to the specified device.
If you want to create an aggregate COM object that includes IStiDevice, you must supply a pointer to the "controlling unknown" in punkOuter. In most cases you will not be creating an aggregate object, so punkOuter should be NULL. Object aggregation and the controlling unknown are described in the Platform SDK documentation and in the Component Object Model Specification.
See Also

IStiDevice::Release

Al hacer la llamada a esta función , pDevice apunta a nil

A ver si alguien me ilumina. Muchas gracias
Responder Con Cita