I have no idea what COM is, just only need to use few methods via COM.
But is there any COM browser that will show methods inside gicen interface? By name or GUID or something.
Does COM stores soem metadata like comments to interfaces etc?
Interfaces defined in a type library (.tlb file, which can be embedded in a DLL) are described in it (the OLE/COM object viewer can show them), but hardly documented in it.
Others are only defined in the Windows headers (or in a third-party library's headers). To view the actual documentation, the best is to look it up on MSDN (or just Google the interface name, which works most of the time).
Related
I've compiled C# code into a DLL, but have little experience with them. My C# code contains a class HelloWorld with a static method Print(). I'd like to use this DLL in VBScript to call the method Print(). I know this is base, but I'm using this as a test for a larger scale project that will be compiled to DLL in the end. What's the declare look like for that and how would the method call look?
Important: Both methods will work only if the DLL exposes a COM interface.
If your dll is registered with the system, use CreateObject with it's ProgID.
Set myObject = CreateObject("MyReallyCoolObject.HelloWorld")
myObject.Print
If your object is not registered on the system, use GetObject with a path to the file containing your object. Make sure your object exposes the proper interface. (The second parameter is optional. Here you can provide a class name if your object exposes more than one.)
Set myObject = GetObject("C:\some\path\helloworld.dll", "appname.HelloWorld")
myObject.Print
I think you might be looking for Registration-Free COM. This SO answer regarding the Microsoft.Windows.ActCtx should help specifically for VBScript.
Keep in mind that COM doesn't support static methods, so you'll have to make your Print method into an instance method.
How to call a .NET DLL from a VBScript
Our qtwebkit-based application is rejected by apple after submission to mac app store. One of the reasons for rejection is the usage of non-public API. I've managed found six of them in the source code for qtwebkit. But I have no where to find the rest. I searched through the source code of our application and the entire source code of QT.
The six non-public api I found in qtwebkit source is:
CFHTTPCookieStorageSetCookieAcceptPolicy
CFURLCacheCopyResponseForRequest
CFURLResponseGetMIMEType
CFURLResponseCopySuggestedFilename
CFURLCacheSetMemoryCapacity
CFURLCacheSetDiskCapacity
Here is the full list of violations found by apple:
The use of non-public APIs can lead to a poor user experience should
these APIs change in the future, and is therefore not permitted. The
following non-public APIs are included in your application:
NSAccessibilityCreateAXUIElementRef
NSAccessibilityHandleFocusChanged
NSAccessibilityUnregisterUniqueIdForUIElement NSAppKitPropertyCreator
NSCarbonWindowPropertyTag NSMouseMovedNotification
_NSDrawCarbonThemeBezel _NSDrawCarbonThemeListBox _NSPopUpCarbonMenu3 _NXShowKeyAndMain from the framework: '/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit'
AXTextMarkerCreate AXTextMarkerGetBytePtr AXTextMarkerGetLength
AXTextMarkerGetTypeID AXTextMarkerRangeCopyEndMarker
AXTextMarkerRangeCopyStartMarker AXTextMarkerRangeCreate
AXTextMarkerRangeGetTypeID CTLineCreateWithUniCharProvider
CoreDragGetCurrentDrag CoreDragSetImage from the framework:
'/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices'
GetNativeWindowFromWindowRef TSMGetInputSourceProperty from the
framework:
'/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon'
CFReadStreamSignalEvent _CFAppVersionCheckLessThan
_CFBundleSetDefaultLocalization _CFStringGetUserDefaultEncoding from the framework:
'/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation'
CFHTTPCookieStorageCopyCookiesForURL CFHTTPCookieStorageDeleteCookie
CFHTTPCookieStorageGetCookieAcceptPolicy
CFHTTPCookieStorageSetCookieAcceptPolicy
CFHTTPCookieStorageSetCookies CFURLCacheCopyResponseForRequest
CFURLCacheSetDiskCapacity CFURLCacheSetMemoryCapacity
CFURLRequestCreateMutableCopy CFURLResponseCopySuggestedFilename
CFURLResponseGetExpectedContentLength CFURLResponseGetHTTPResponse
CFURLResponseGetMIMEType CFURLResponseGetURL
CFURLResponseSetExpectedContentLength CFURLResponseSetMIMEType
_CFNetworkHTTPConnectionCacheGetLimit _CFNetworkHTTPConnectionCacheSetLimit _CFURLCacheCopyCacheDirectory _CFURLRequestCreateArchiveList _CFURLRequestCreateFromArchiveList _CFURLResponseCreateArchiveList _CFURLResponseCreateFromArchiveList _CFURLResponseGetSSLCertificateContext _LSGetCurrentApplicationASN _LSSetApplicationInformationItem _kLSDisplayNameKey kCFStreamPropertyCONNECTAdditionalHeaders
kCFStreamPropertyCONNECTProxy kCFStreamPropertyCONNECTProxyHost
kCFStreamPropertyCONNECTProxyPort kCFStreamPropertyCONNECTResponse
kCFURLResponseExpectedContentLengthUnknown from the framework:
'/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices'
NSPopAutoreleasePool NSPushAutoreleasePool from the framework:
'/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation'
CARenderCGDestroy CARenderCGNew CARenderCGRender
CARenderNotificationAddObserver CARenderNotificationRemoveObserver
CARenderServerGetPort CARenderServerStart CARenderUpdateAddContext
CARenderUpdateAddRect CARenderUpdateBegin CARenderUpdateFinish
kCAContextPortNumber from the framework:
'/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore'
If you have defined methods in your source code with the same names as
the above-mentioned APIs, we suggest altering your method names so
that they no longer collide with Apple's private APIs to avoid your
application being flagged in future submissions.
Additionally, one or more of the above-mentioned APIs may reside in a
library included with your application. If you do not have access to
the library's source, you may be able to search the compiled binary
using "strings" or "otool" command line tools. The "strings" tool can
output a list of the methods that the library calls and "otool -ov"
will output the Objective-C class structures and their defined
methods. These techniques can help you narrow down where the
problematic code resides.
I've finally traced down to the location where these so-called privatate apis are called. They are called from inside webkit. webkit uses a webkit system interface library which is directly supplied from apple in the format of compiled static library+header file. More specifically, they are the four files located under the path src\3rdparty\webkit\WebKitLibraries:
libWebKitSystemInterfaceLeopard.a
libWebKitSystemInterfaceLion.a
libWebKitSystemInterfaceMountainLion.a
libWebKitSystemInterfaceSnowLeopard.a
I always wondered if it's really a private api, who else would know how to call it without any documentation? Now it's turned out to be apple itself. Since neither nokia or digia has the source code to these libraries, there is probably nothing they can do about it.
Now isn't it ironic that any qtwebkit-based apps will be rejected by apple due to private api access from libraries created?
Please correct me if I am wrong or miss anything. I really hope I am wrong.
The global VB6 error handler product referred to in the following link claims to "install a small callback hook into the VBE6 debugger":
http://www.everythingaccess.com/simplyvba/globalerrorhandler/howitworks.htm
I would like to implement this product myself because I would like more control over what it is doing. How is the above product likely to be achieving what it does?
The product you are looking at is a COM component. From the documentation that is available on the web site, it sounds like the COM component implements particular component classes. The first thing to do, if you already have the product, would be to fire up SysInternals procmon, run regsvr32 on the DLL, and figure out what component classes are implemented from the registry entries that are created. Once you know this, MSDN may be able to tell you what interfaces correspond to those component classes.
Microsoft developed a framework called Active Scripting that allows you to host a script engine and inject debugging capabilities. If one assumes that VB6 produces an exe that ties into that framework, you might be able to do:
Create a COM component that implements IApplicationDebugger
Implement IApplicationDebugger::onHandleBreakPoint to be able to respond to errors in the VB code
Read MSDN KB Q222966 to find out how to call back to VB from onHandleBreakPoint
It looks like the product injects the ErrEx class using IActiveScript::AddNamedItem. To provide the same behaviour, Implement IActiveScriptSite::GetItemInfo on the same COM component to return a pointer to an instance of (and the associated TypeInfo for) a COM component that implements the same interface as ErrEx. In your implementation of ErrEx.EnableGlobalErrorHandler you would do the following:
CoCreateInstance inproc Process Debug Manager
Cast reference to IRemoteDebugApplication
Register an instance of your IApplicationDebugger component using IRemoteDebugApplication::ConnectDebugger
I glossed over calling IActiveScript::AddNamedItem because I have no idea how you get a pointer to IActiveScript from a running process. Also, I don't know if creating a new instance of the Process Debug Manager will work, or if you somehow have to hook into an existing instance.
I apologize for the confusing explanation, missing information, and glossing over large parts of the process, but this is going waaay back...
You will want to read the Active Scripting APIs article at MSDN.
The Windows Phone 7 project I'm working on has 2 UIs, and a core 'engine' of functionality with some pages that are common. I'd like my user interface to pass an object into one of these common pages in the core assembly.
Currently I can navigate to pages in the core assembly from the UI assembly. However, it is my understanding that each assembly has it's own Isolated storage, is that correct?
If I can share Isolated storage, I can use that, I'm just not sure how to get the two assemblies to use it together.
What's the best practice?
I tried googling this: 'wp7 pass object between assemblies'
More Info:
This would be 1 application with two assemblies. Something like this:
CustomerUI (project)
- MainPage.xaml
- App.xaml
CoreFuncs (project)
- CustomerData.cs
- EditCustomer.xaml
SalesRepUI (project)
- MainPage.xaml
- App.xaml
Both CustomerUI and SalesRepUI would use the EditCustomer page and customerData object. So, from MainPage a CustomerData object is instantiated, then a user could click 'Edit User' which would navigate to the common EditCustomer.xaml page. We would want to pass in the already instantiated CustomerData object. (For the purpose of this discussion...)
As I know, there is one Isolated storage per application, not per assembly. So you can try pass your objects through it if you like.
It depends are these two separate applications or two assemblies?
Isolated storage is isolated around the running application. This means each app has its own storage that cannot be accessed from a different app. The only ways to share data between two apps are:
A WebService/or TCP service in 7.5: You would upload the data from one app and download the data into a separate application.
User performed tasks: Copy and Paste/Sending an Email
However if this is just one application you will be able to access the isolated storage between the assemblies just by reading and writing to the files. The only thing to be aware of is file locking, make sure you close files any before you attempt to read from them from a separate dll/assembly.
Sorry, Sorry, I found what I wanted, I was thinking too hard.
PhoneApplicationService.Current.State["keyName"] = object; was exactly what I wanted. Not sure if its the best way, but for me, it works. Just throw my settings class or whatever in there, and catch it on the other side in the page.xaml code.
I would recommend using the Messenger class in the MVVM Light toolkit:
http://blog.galasoft.ch/archive/2009/09/27/mvvm-light-toolkit-messenger-v2-beta.aspx
Both of your assemblies can reference a single shared assembly; that assembly can contain a type that you use to hold data passed via the messenger.
Like the title says, i want to disable images, and ActiveX Controls in the vb6 webbrowser control using DLCTL_NO_RUNACTIVEXCTLS and DLCTL_NO_DLACTIVEXCTLS
Microsoft talk about it here: http://msdn.microsoft.com/en-us/library/aa741313.aspx
But i dont see any way to access IDispatch::Invoke from the vb6 application.
Any help would be greatly appreciated.
I do not think VB6 let you to add the ambient properties. Try host the ActiveX in another container (e.g. an ActiveX host written by yourself - but I do not know how much time you want to invest to declare VB-friendly OLE interfaces and implement them - or use another ActiveX like the one at http://www.codeproject.com/KB/atl/vbmhwb.aspx instead.
You don't access IDispatch::Invoke in VB6, you just write you method and IDispatch is automagically implemented.
Public Function DlControl() As Long
DlControl = DLCTL_NO_DLACTIVEXCTLS Or ...
End FUnction
Then just open Tools->Procedure Attributes and for DlControl function open Advanced and assign Procedure ID to -5512 (DISPID_AMBIENT_DLCONTROL). That's first part.
Second part is to set the client site to you custom implementation of IOleClientSite. You'll need a custom typelib, try Edanmo's OLELIB for declaration of these interfaces.
Here is a delphi sample how to hook your implementation of IOleClientSite. Apparently you'll alse have to call OnAmbientPropertyChange at some point.