As far as I understand you are using pure Visual Basic 6 (stand-alone). What do you mean by?
There is another method swApp.GetPreviewBitmap, it create bitmap(stdole.StdPicture) and works well,but it can be use only in VBA environment.
VBA and Visual Basic 6 are basically the same things. Why do you think this method won't work in VB6? I do not have VB6 Studio so cannot check, but I believe this should work in exactly the same way as VBA macro.
That's not "I think", I had tested to use swApp.GetPreviewBitmap in VB6,so I'm sure this method can not work in VB6.
The following words come from Solidworks API help, just about this method.
Currently only in-process applications (that is, macros or add-ins) can use this method; out-of-process applications (that is, executables) will get an automation error because the IPictureDisp interface cannot be marshalled across process boundaries. This is a Microsoft behavior by design. See the Microsoft Knowledge Base for details.
This method is not supported in macros or out-of-process applications in SOLIDWORKS x64.
Thanks for your advice!
The Document Managet Api needs a diffenrnt license key for new version of solidworks.
but I want to create a application that can works well with future version of solidworks
Ok, got it, thanks for the clarification. You need to use GetPreviewPNGBitmapBytes/GetPreviewBitmapBytes so it can be extracted for out-of-process application for any file version. Here is example in C#: Extract PNG Preview Image From The Active Configuration
Thanks for your Help!
These 2 mdthods (GetPreviewPNGBitmapBytes/GetPreviewBitmapBytes ) belong to Document Managet Api.
The Document Managet Api needs a different license key for new version of solidworks.
I had created a application in vb6 that can works well with future version of solidworks(I had tested it with the version of solidworks from 2007 to 2017,and works well.)
And now,I want to add a function to preview solidworks models.
I find a api PreviewDoc, syntax: swApp.PreviewDoc(HWnd, FullName)
but i don't know how to use it,
This method has the same constraint:
HWnd Window handle where you want the preview bitmap to display; this pointer is not valid across processes; therefore, this method only works if your application is implemented as a DLL
It seems that there is no good solution about this issue.
But thank you all the same!
Now I have to do like this:
Click one row in the table,then open the model in that row with solidworks automatically.
this action may take a lot of time if the computer has a week performance.
Today I Solved this problem by myself !
I create a vba macro to export all preview BMP files of an assembly model and its sub models to a folder,
after open an assembly model in Solidworks, in my standalone app,use swapp.runmacro(...) to run this macro in solidworks,
and then the BMP files of all models (include sub models) is ready for me!
When I need a preview of a model,just find its BMP file and show it !
and before my standalone app exit ,delete all the BMP files.
This is a perfect solution!