late-binding

How can I load a VBA library reference and use it in the same procedure?

天涯浪子 提交于 2019-12-10 10:07:57
问题 I have a VBA script for Excel that adds a small procedure in the active workbook. The final version will add a procedure that auto-saves backup copies of the workbook. The code requires the Microsoft Visual Basic for Applications Extensibility 5.3 library which I can add manually, but I'm interested in having a single script that can add that library into Excel and then use it. Here's the code that adds the library reference to Excel. It works. On Error Resume Next ' If library already

PHP __DIR__ evaluated runtime (late binding)?

烈酒焚心 提交于 2019-12-09 06:07:40
问题 Is it somehow possible to get the location of PHP file, evaluated at runtime? I am seeking something similar to the magic constant __DIR__ , but evaluated at runtime, as a late binding. Similar difference with self and static : __DIR__ ~ self ??? ~ static My goal is defining a method in an abstract class, using __DIR__ which would be evaluated respectively for each heir class. Example: abstract class Parent { protected function getDir() { // return __DIR__; // does not work return <<I need

Question about CreateObject() in VB6 / VBA

[亡魂溺海] 提交于 2019-12-08 15:04:29
问题 I can do this: Dim fso As New FileSystemObject or I can do this: Dim fso As Object Set fso = CreateObject("Scripting.FileSystemObject") How do I know what string to use for CreateObject? For example, how would I know to use the "Scripting." part of "Scripting.FileSystemObject"? Where do you go to look that up? 回答1: It is the ProgID of the component which is registered in Windows registry under HKCR key: HKEY_CLASSES_ROOT\Scripting.FileSystemObject ProgID's are human readable identifiers for

Get a static property of an instance

爷,独闯天下 提交于 2019-12-08 14:41:34
问题 If I have an instance in PHP, what's the easiest way to get to a static property ('class variable') of that instance ? This $classvars=get_class_vars(get_class($thing)); $property=$classvars['property']; Sound really overdone. I would expect $thing::property or $thing->property EDIT: this is an old question. There are more obvious ways to do this in newer PHP, search below. 回答1: You need to lookup the class name first: $class = get_class($thing); $class::$property $property must be defined as

Late binding Excel with .NET

烂漫一生 提交于 2019-12-08 11:29:45
问题 I need to add values for my "BookMarks" in a Word document. There I do need to achieve this using late binding. I have extracted upto book mark, but how do I change the value? object bookMark = @"OfferRef"; Type applicationType = Type.GetTypeFromProgID("Word.Application"); object applicationObject = Activator.CreateInstance(applicationType); object documentsObject = applicationType.InvokeMember("Documents", System.Reflection.BindingFlags.GetProperty, null, applicationObject, null);

PHP Late Static Binding in Singleton

拥有回忆 提交于 2019-12-08 07:56:58
问题 I has this code from some article on habrahabr.ru: abstract class Singleton { protected static $_instances = array(); protected function __construct() { } public static function getInstance() { $class = \get_called_class(); if ( !isset( static::$_instances[$class] ) ) static::$_instances[$class] = new static; return static::$_instances[$class]; } } Auhtor use it as, for example, class B extends Singleton { private $_a = 10; } But I can not to understand main difference between "static" and

PHP Late Static Binding in Singleton

你离开我真会死。 提交于 2019-12-07 07:54:27
I has this code from some article on habrahabr.ru: abstract class Singleton { protected static $_instances = array(); protected function __construct() { } public static function getInstance() { $class = \get_called_class(); if ( !isset( static::$_instances[$class] ) ) static::$_instances[$class] = new static; return static::$_instances[$class]; } } Auhtor use it as, for example, class B extends Singleton { private $_a = 10; } But I can not to understand main difference between "static" and "self" in this case: for example, if we define $_instances as public and try to create some another class

Createinstance() - Am I doing this right?

不问归期 提交于 2019-12-07 05:29:57
问题 I'm trying to put together a plugins system with .NET, and I'm not sure if I'm doing it correctly. The basis of the system is that a specific directory ({apppath}/Plugins/) will have a bunch of precompiled DLLs, and I want to look through each one with reflection, and for every class available, if it inherits a specific base class (this is defined in yet another DLL, but I'll go into that later), then create an instance of it and call a specific function in said instance. Public Sub

How to find out a COM prog id?

只愿长相守 提交于 2019-12-07 00:13:16
问题 I'd like to access a COM library via late binding. How can I find out its progID? Type oClassType = Type.GetTypeFromProgID("THE MISSING PROGID"); 回答1: The progID is generally going to be of the form Library.Class, you can view what classes a COM library exposes using oleview. The feature you want in oleview is View TypeLib (three little red triangles). The Library name will be at the top and you will want to use the name of the class as seen under CoClasses 来源: https://stackoverflow.com

WPF Assigning control Properties using reflection in c sharp

送分小仙女□ 提交于 2019-12-06 05:34:38
I am trying to create an application that creates objects from data that is read from an XML file. Using reflection I have managed to create the objects I need and assign some of the properties like primitive types and ENUM types. For primitive types where property is a Dictionary entry with the Property name to change and the value to set type.GetProperty((string)property.Key).SetValue(control, Convert.ChangeType((string)property.Value, propertyType, null), null); and for ENUM types object desiredPropertyValue = Enum.Parse(propertyType, (string)property.Value); propertyInfo.SetValue(control,