Author Topic: COM 64  (Read 20368 times)

0 Members and 2 Guests are viewing this topic.

JRS

  • Guest
COM 64
« on: August 09, 2018, 01:09:10 PM »
I'm worried and curious where COM is going with 64 bit? Here is a way to access 32 bit COM objects from 64 bit languages.

Using a 32bit COM object in a 64bit environment

Charles Pegge

  • Guest
Re: COM 64
« Reply #1 on: August 09, 2018, 01:53:01 PM »
I think that would be an unusual situation. All the Windows OS COM objects have dual access, as far as I know. Certainly SAPI (speech) runs in 32bit and 64bit.

  • Guest
Re: COM 64
« Reply #2 on: August 09, 2018, 02:38:36 PM »
Forget outdated COM servers. Even VB6 mscomct2.ocx no longer works with Windows 10 after the last "big update". I had an example that used the MonthView control, and it no longer works even if compiled with 32 bit.


JRS

  • Guest
Re: COM 64
« Reply #3 on: August 09, 2018, 02:50:16 PM »
I don't seem to have any problems running COM/OLE/VB6 interfaces in Windows 10 using the Script BASIC COM extension module. Admittedly I'm not on the latest and greatest Win10 version and I'm running the 32 bit not 64 bit version of the OS.

I'm not using tbe standard mscomct2 with SB. All Windows controls per version of Windows along with current theming work.
« Last Edit: August 09, 2018, 03:06:21 PM by John »

  • Guest
Re: COM 64
« Reply #4 on: August 09, 2018, 03:06:10 PM »
> Admittedly I'm not on the latest and greatest Win10 version and I'm running the 32 bit not 64 bit version of the OS.
> I'm not using tbe standard mscomct2 with SB.

That says all. I had no problems with Windows 7 64 bit, but it no longer works with the version of Windows 10 that I'm using.
« Last Edit: August 09, 2018, 03:12:59 PM by José Roca »

JRS

  • Guest
Re: COM 64
« Reply #5 on: August 09, 2018, 04:24:10 PM »
I'll update my Windows 10 to 1803 and see if SB still runs. The update process is going to take a long time to complete based on how it's going now.

There is still a lot of VB6 code out there people depend on.
« Last Edit: August 09, 2018, 08:34:07 PM by John »

JRS

  • Guest
Re: COM 64
« Reply #6 on: August 10, 2018, 07:32:11 AM »
All seems fine on Windows 10 1803 with the Script BASIC VB6 based IDE/Debugger.

JRS

  • Guest
Re: COM 64
« Reply #7 on: August 10, 2018, 12:31:44 PM »
José,

You are correct with the MonthView OCX not running on Windows 10 Build 1803. It worked fine on my Windows 7 32 bit OS. (VirtualBox's on Linux)

Do you know where it is failing?

I wonder if you could use the Common Controls Replacement I'm using with VB6?
« Last Edit: August 10, 2018, 04:10:10 PM by John »

JRS

  • Guest
Re: COM 64
« Reply #8 on: August 10, 2018, 09:46:59 PM »
The SAPI example worked in Windows 10 1803.

Code: Script BASIC
  1. IMPORT com.sbi
  2.  
  3. voice = COM::CREATE(:SET, "SAPI.SpVoice")
  4. FOR beers = 99 to 1 STEP -1
  5.   IF beers = 1 THEN
  6.     beers_str = "1 bottle of beer"
  7.   ELSE
  8.     beers_str = beers & " bottles of beer"
  9.   END IF
  10.   COM::CBN(voice, "speak", :CALL, beers_str & " on the wall. Take one down, pass it around.")
  11. NEXT
  12. COM::RELEASE(voice)
  13.  

Note: On Windows 10, it's a male voice and sounds less like a computer.


JRS

  • Guest
Re: COM 64
« Reply #9 on: August 10, 2018, 10:33:42 PM »
This is an example of Script BASIC calling a VB6 form saved as an OCX control and doing a callback from VB6 to SB functions.

Code: Script BASIC
  1. import com.sbi
  2.  
  3. 'in the VB6 GUI
  4. 'this one uses SBCallBackEx which supports multiple types and args
  5. 'return values can be either string or long.
  6. function Button1_Click(arg, arg1, arg2, arg3, arg4, arg5)
  7.         print "Button1_Click arg=", arg, "\n"
  8.         print "Button1_Click arg1=", arg1, "\n"
  9.         print "Button1_Click arg2=", arg2, "\n"
  10.         print "Button1_Click arg3=", arg3, "\n"
  11.         print "Button1_Click arg4=", arg4, "\n"
  12.         print "Button1_Click arg5=", arg5, "\n"
  13.         Button1_Click = arg + 1
  14. end function
  15.  
  16. 'in the VB6 GUI
  17. 'this one uses SBCallBack it only takes one long arg. return value is long
  18. function Button2_Click(arg)
  19.         print "Back in script basic Button2_Click arg=", arg, "\n"
  20.         Button2_Click = arg * 2
  21. end function
  22.  
  23. obj = COM::CREATE(:SET, "VB6.Sample")
  24.  
  25. if obj = 0 then
  26.     print "CreateObject failed!\n"
  27. else
  28.         print "obj = ", obj, "\n"
  29.  
  30.         oCollection = COM::CBN(obj, "CallBackHandlers", :GET)
  31.     print "oCollection = ", oCollection, "\n"
  32.  
  33.     COM::CBN(oCollection, "Add", :CALL, ADDRESS(Button1_Click()), "frmCallBack.cmdOp1_Click" )
  34.     COM::CBN(oCollection, "Add", :CALL, ADDRESS(Button2_Click()), "frmCallBack.cmdOp2_Click" )
  35.  
  36.     retVal = COM::CBN(obj, "LaunchCallBackForm", :CALL, 21)
  37.     print "LaunchCallBackForm returned ", retVal, "\n"
  38.  
  39.     COM::RELEASE(obj)
  40.     print "test complete!\n"
  41. end if
  42.  


C:\ScriptBASIC\com>scriba cb.sb
obj = 8216080
oCollection = 8273656
Button1_Click arg=21
Button1_Click arg1=two
Button1_Click arg2=3
Button1_Click arg3=four
Button1_Click arg4=5
Button1_Click arg5=8274128
Back in script basic Button2_Click arg=22
LaunchCallBackForm returned 44
test complete!

C:\ScriptBASIC\com>


This is the VB6 Callback OCX form code.

Code: Visual Basic
  1. 'this is the simple callback it takes one long arg and returns a long
  2. Private Declare Function ext_SBCallBack Lib "COM.dll" Alias "SBCallBack" (ByVal EntryPoint As Long, ByVal arg As Long) As Long
  3. Private Declare Function eng_SBCallBack Lib "sb_engine.dll" Alias "SBCallBack" (ByVal EntryPoint As Long, ByVal arg As Long) As Long
  4.  
  5.  
  6. 'this extended version will take a variant array as the argument and it will pass
  7. 'them as arguments to the callback function. It supports Long,Byte,Integer,Object, and string inputs
  8. 'The variant return result can be either a long or a string
  9. 'the arg count of the script basic function actually does not have to line up to the array count.
  10. 'extra args in the script declare will just be undef, or two few cause no problems either..
  11. Private Declare Function ext_SBCallBackEx Lib "COM.dll" Alias "SBCallBackEx" (ByVal EntryPoint As Long, ByRef v As Variant) As Variant
  12. Private Declare Function eng_SBCallBackEx Lib "sb_engine.dll" Alias "SBCallBackEx" (ByVal EntryPoint As Long, ByRef v As Variant) As Variant
  13.  
  14.  
  15. Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
  16.  
  17. Private m_owner As Sample
  18.  
  19. Private Function TriggerCallBack(nodeID As Long, argValue As Long)
  20.  
  21.     'this little trick is so this works for both the standard COM extension,
  22.    'as well as the embedded sb_engine.dll project i am working on..
  23.    If GetModuleHandle("COM.dll") <> 0 Then
  24.         TriggerCallBack = ext_SBCallBack(nodeID, argValue)
  25.     ElseIf GetModuleHandle("sb_engine.dll") <> 0 Then
  26.         TriggerCallBack = eng_SBCallBack(nodeID, argValue)
  27.     Else
  28.         MsgBox "Could not find the extension dll or the sb_engine.dll to get the sbcallback export from?", vbExclamation
  29.     End If
  30.    
  31. End Function
  32.  
  33. Private Function TriggerCallBackEx(nodeID As Long, v() As Variant)
  34.  
  35.     'this little trick is so this works for both the standard COM extension,
  36.    'as well as the embedded sb_engine.dll project i am working on..
  37.    If GetModuleHandle("COM.dll") <> 0 Then
  38.         TriggerCallBackEx = ext_SBCallBackEx(nodeID, v)
  39.     ElseIf GetModuleHandle("sb_engine.dll") <> 0 Then
  40.         TriggerCallBackEx = eng_SBCallBackEx(nodeID, v)
  41.     Else
  42.         MsgBox "Could not find the extension dll or the sb_engine.dll to get the sbcallback export from?", vbExclamation
  43.     End If
  44.    
  45. End Function
  46.  
  47. Function ShowCallBackForm(defVal As Long, owner As Sample) As Long
  48.     On Error Resume Next
  49.     Set m_owner = owner
  50.     txtValue = defVal
  51.     Me.Show 1
  52.     Set m_owner = Nothing
  53.     ShowCallBackForm = CLng(txtValue)
  54.     Unload Me
  55. End Function
  56.  
  57. Private Sub cmdOp1_Click()
  58.  
  59.     Dim nodeID As Long
  60.     Dim arg As Long
  61.    
  62.     On Error Resume Next
  63.     nodeID = m_owner.CallBackHandlers("frmCallBack.cmdOp1_Click")
  64.    
  65.     If nodeID = 0 Then
  66.         MsgBox "Script writer forgot to register a callback handler for me..", vbInformation
  67.         Exit Sub
  68.     End If
  69.    
  70.     Dim tmp(5)
  71.     tmp(0) = CLng(txtValue)
  72.     tmp(1) = "two"
  73.     tmp(2) = 3
  74.     tmp(3) = "four"
  75.     tmp(4) = 5
  76.     Set tmp(5) = Me
  77.  
  78. '    Dim tmp2(5) As Long
  79. '    For i = 0 To UBound(tmp2)
  80. '        tmp(2) = i
  81. '    Next
  82.    
  83.     arg = CLng(txtValue)
  84.     retval = TriggerCallBackEx(nodeID, tmp)
  85.    
  86.     If TypeName(retval) = "String" Then
  87.         MsgBox "String return received: " & retval
  88.     ElseIf TypeName(retval) = "Long" Then
  89.         txtValue = retval
  90.     Else
  91.         'returns type Empty on failure..
  92.        MsgBox "Typename(retVal) = " & TypeName(retval) & "  Value=" & retval
  93.     End If
  94.  
« Last Edit: August 10, 2018, 11:22:56 PM by John »

JRS

  • Guest
Re: COM 64
« Reply #10 on: August 11, 2018, 11:20:25 AM »
Does your FB COM includes work on Windows 10 1803 with OCX controls other than the MonthView?

Here is the MonthView OCX running in VB6 under Windows 10 1803.

« Last Edit: August 11, 2018, 11:56:23 AM by John »

José Roca

  • Guest
Re: COM 64
« Reply #11 on: August 11, 2018, 12:16:32 PM »
Don't know. I'm not interested in these old 32-bit only OCXs. I only wrote the example to test my OLE Container.

JRS

  • Guest
Re: COM 64
« Reply #12 on: August 11, 2018, 12:22:45 PM »
Based on the first post in this thread, it looks like one can use 32 bit OCX controls from a 64 bit environment.

Does this mean there will be no traditional 32 bit OCX support in Paul's FB GUI designer?
« Last Edit: August 11, 2018, 12:51:10 PM by John »

JRS

  • Guest
Re: COM 64
« Reply #13 on: August 11, 2018, 03:31:54 PM »
What do you think the merit is of keeping VB6 applications running under current OS standards?

My experience has been companies are more willing to retrofit existing code than start over on some other platform.

José Roca

  • Guest
Re: COM 64
« Reply #14 on: August 11, 2018, 04:23:59 PM »
> Does this mean there will be no traditional 32 bit OCX support in Paul's FB GUI designer?

In the editor? Of course not. You can do it using the OLE Container and the Dispatch class of my framework. The only OCX that interests me is the WebBrowser control.