Class: WIN32OLE_VARIABLE

Inherits:
Object
  • Object
show all
Defined in:
lib/win32ole-pr.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#indexObject

Returns the value of attribute index.



3450
3451
3452
# File 'lib/win32ole-pr.rb', line 3450

def index
  @index
end

#nameObject Also known as: to_s

Returns the value of attribute name.



3450
3451
3452
# File 'lib/win32ole-pr.rb', line 3450

def name
  @name
end

#pTypeInfoObject

Returns the value of attribute pTypeInfo.



3450
3451
3452
# File 'lib/win32ole-pr.rb', line 3450

def pTypeInfo
  @pTypeInfo
end

Instance Method Details

#inspectObject



3622
3623
3624
# File 'lib/win32ole-pr.rb', line 3622

def inspect
  "#<#{self.class}:#{self.to_s}=#{self.value.inpect}>"
end

#ole_typeObject



3476
3477
3478
# File 'lib/win32ole-pr.rb', line 3476

def ole_type
  ole_variable_ole_type(@pTypeInfo, @index)
end

#ole_type_detailObject



3503
3504
3505
# File 'lib/win32ole-pr.rb', line 3503

def ole_type_detail
  ole_variable_ole_type_detail(@pTypeInfo, @index)
end

#ole_variable_kind(pTypeInfo, var_index) ⇒ Object



3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
# File 'lib/win32ole-pr.rb', line 3563

def ole_variable_kind(pTypeInfo, var_index)
  kind = "UNKNOWN"
  lpVtbl = 0.chr * 4
  table = 0.chr * 88
  memcpy(lpVtbl, pTypeInfo, 4)
  memcpy(table, lpVtbl.unpack('L').first, 88)
  table = table.unpack('L*')

  getVarDesc = Win32::API::Function.new(table[6], 'PLP', 'L')
  releaseVarDesc = Win32::API::Function.new(table[21], 'PP', 'L')
  p = 0.chr * 4
  hr = getVarDesc.call(pTypeInfo, var_index, p)
  pVarDesc = p.unpack('L').first
  return kind if hr != S_OK
  varDesc = 0.chr * 36
  memcpy(varDesc, pVarDesc, 36)
  case varDesc[32, 4].unpack('L').first
    when VAR_PERINSTANCE
      kind = PERINSTANCE
    when VAR_STATIC
      kind = STATIC
    when VAR_CONST
      kind = CONSTANT
    when VAR_DISPATCH
      kind = DISPATCH
  end
  releaseVarDesc.call(pTypeInfo, pVarDesc)
  kind
end

#ole_variable_ole_type(pTypeInfo, var_index) ⇒ Object



3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
# File 'lib/win32ole-pr.rb', line 3454

def ole_variable_ole_type(pTypeInfo, var_index)
  lpVtbl = 0.chr * 4
  table = 0.chr * 88
  memcpy(lpVtbl, pTypeInfo, 4)
  memcpy(table, lpVtbl.unpack('L').first, 88)
  table = table.unpack('L*')

  getVarDesc = Win32::API::Function.new(table[6], 'PLP', 'L')
  releaseVarDesc = Win32::API::Function.new(table[21], 'PP', 'L')
  p = 0.chr * 4
  hr = getVarDesc.call(pTypeInfo, var_index, p)
  pVarDesc = p.unpack('L').first
  if hr != S_OK
    raise WIN32OLERuntimeError, "failed to GetVarDesc"
  end
  varDesc = 0.chr * 36
  memcpy(varDesc, pVarDesc, 36)
  type = WIN32OLE_TYPE.ole_typedesc2val(pTypeInfo, varDesc[12, 8], nil)
  releaseVarDesc.call(pTypeInfo, pVarDesc)
  type
end

#ole_variable_ole_type_detail(pTypeInfo, var_index) ⇒ Object



3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
# File 'lib/win32ole-pr.rb', line 3480

def ole_variable_ole_type_detail(pTypeInfo, var_index)
  type = []
  lpVtbl = 0.chr * 4
  table = 0.chr * 88
  memcpy(lpVtbl, pTypeInfo, 4)
  memcpy(table, lpVtbl.unpack('L').first, 88)
  table = table.unpack('L*')

  getVarDesc = Win32::API::Function.new(table[6], 'PLP', 'L')
  releaseVarDesc = Win32::API::Function.new(table[21], 'PP', 'L')
  p = 0.chr * 4
  hr = getVarDesc.call(pTypeInfo, var_index, p)
  pVarDesc = p.unpack('L').first
  if hr != S_OK
    raise WIN32OLERuntimeError, "failed to GetVarDesc"
  end
  varDesc = 0.chr * 36
  memcpy(varDesc, pVarDesc, 36)
  WIN32OLE_TYPE.ole_typedesc2val(pTypeInfo, varDesc[12, 8], type)
  releaseVarDesc.call(pTypeInfo, pVarDesc)
  type
end

#ole_variable_value(pTypeInfo, var_index) ⇒ Object



3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
# File 'lib/win32ole-pr.rb', line 3507

def ole_variable_value(pTypeInfo, var_index)
  val = nil
  lpVtbl = 0.chr * 4
  table = 0.chr * 88
  memcpy(lpVtbl, pTypeInfo, 4)
  memcpy(table, lpVtbl.unpack('L').first, 88)
  table = table.unpack('L*')

  getVarDesc = Win32::API::Function.new(table[6], 'PLP', 'L')
  releaseVarDesc = Win32::API::Function.new(table[21], 'PP', 'L')
  p = 0.chr * 4
  hr = getVarDesc.call(pTypeInfo, var_index, p)
  pVarDesc = p.unpack('L').first
  return nil if hr != S_OK

  varDesc = 0.chr * 36
  memcpy(varDesc, pVarDesc, 36)
  if varDesc[32, 4].unpack('L').first == VAR_CONST
    val = WIN32OLE.ole_variant2val(varDesc[8, 4].unpack('L').first)
  end
  releaseVarDesc.call(pTypeInfo, pVarDesc)
  val
end

#ole_variable_varkind(pTypeInfo, var_index) ⇒ Object



3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
# File 'lib/win32ole-pr.rb', line 3597

def ole_variable_varkind(pTypeInfo, var_index)
  kind = nil
  lpVtbl = 0.chr * 4
  table = 0.chr * 88
  memcpy(lpVtbl, pTypeInfo, 4)
  memcpy(table, lpVtbl.unpack('L').first, 88)
  table = table.unpack('L*')

  getVarDesc = Win32::API::Function.new(table[6], 'PLP', 'L')
  releaseVarDesc = Win32::API::Function.new(table[21], 'PP', 'L')
  p = 0.chr * 4
  hr = getVarDesc.call(pTypeInfo, var_index, p)
  pVarDesc = p.unpack('L').first
  return kind if hr != S_OK
  varDesc = 0.chr * 36
  memcpy(varDesc, pVarDesc, 36)
  kind = varDesc[32, 4].unpack('L').first
  releaseVarDesc.call(pTypeInfo, pVarDesc)
  kind
end

#ole_variable_visible(pTypeInfo, var_index) ⇒ Object



3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
# File 'lib/win32ole-pr.rb', line 3535

def ole_variable_visible(pTypeInfo, var_index)
  visible = false
  lpVtbl = 0.chr * 4
  table = 0.chr * 88
  memcpy(lpVtbl, pTypeInfo, 4)
  memcpy(table, lpVtbl.unpack('L').first, 88)
  table = table.unpack('L*')
  getVarDesc = Win32::API::Function.new(table[6], 'PLP', 'L')
  releaseVarDesc = Win32::API::Function.new(table[21], 'PP', 'L')
  p = 0.chr * 4
  hr = getVarDesc.call(pTypeInfo, var_index, p)
  pVarDesc = p.unpack('L').first
  return visible if hr != S_OK
  varDesc = 0.chr * 36
  memcpy(varDesc, pVarDesc, 36)
  if (varDesc[28, 2].unpack('S').first & (VARFLAG_FHIDDEN |
      VARFLAG_FRESTRICTED |
      VARFLAG_FNONBROWSABLE)) == 0
    visible = true
  end
  releaseVarDesc.call(pTypeInfo, pVarDesc)
  visible
end

#valueObject



3531
3532
3533
# File 'lib/win32ole-pr.rb', line 3531

def value
  ole_variable_value(@pTypeInfo, @index)
end

#variable_kindObject



3593
3594
3595
# File 'lib/win32ole-pr.rb', line 3593

def variable_kind
  ole_variable_kind(@pTypeInfo, @index)
end

#varkindObject



3618
3619
3620
# File 'lib/win32ole-pr.rb', line 3618

def varkind
  ole_variable_varkind(@pTypeInfo, @index)
end

#visible?Boolean

Returns:

  • (Boolean)


3559
3560
3561
# File 'lib/win32ole-pr.rb', line 3559

def visible?
  ole_variable_visible(@pTypeInfo, @index)
end