당신은 아마이 코드를 조금 수정해야합니다,하지만 당신이 찾고있는 것을 대략 않습니다. 먼저 "Typelib 정보", TLBINF32.dll에 대한 참조를 추가해야합니다. 이것이 Windows의 일부인지 또는 내 컴퓨터에 설치 한 수많은 SDK 중 일부와 함께 제공되는지는 잘 모르겠지만 System32 폴더에 있습니다.
COM 개체의 속성을 설정한다고 가정하므로 "속성 넣기"함수를 호출하여 개체의 값을 설정합니다. 이러한 속성의 데이터 유형을 확인해야 할 수도 있습니다. 코드에서 데이터 유형 변환을 수행하지 않았습니다.
코드는 다음과 같습니다 심지어 반사를 사용하여 C#에서이 작업을 수행 할 것
'Define the variables
Dim tliApp As TLI.TLIApplication
Dim typeinfo As TLI.typeinfo
Dim interface As TLI.InterfaceInfo
Dim member As TLI.MemberInfo
'Initialize typelib reflector
Set tliApp = New TLI.TLIApplication
'Get the type information about myObject (the COM object you want to process)
Set typeinfo = tliApp.ClassInfoFromObject(myObject)
'Set all properties of all the object's interfaces
For Each interface In typeinfo.Interfaces
For Each member In interface.Members
'If this is a "property put" function
If member.InvokeKind = INVOKE_PROPERTYPUT Then
'Invoke the mebmer and set someValue to it.
'Note that you'll probably want to check what datatype to use and do some more error checking
CallByName myObject, member.Name, VbLet, someValue
End If
Next
Next
출처
2011-11-10 08:30:30
GTG
. 이 작업을 수행하는 것에 대해 생각해 보셨습니까? –
이 질문을보고 싶을 수도 있습니다 : http://stackoverflow.com/questions/547903/self-inspection-of-vb6-udts – GTG
@parapurarajkumar, 왜 C#에서 리플렉션을 사용하여이 작업을 수행하지 않습니까? 나는이 문제를 해결하는 함수를 만들기 위해 노력하고있다. – Ben