Baanboard.com

Go Back   Baanboard.com > Forum > Baan SIGs > AFS/DDC/OLE: Function servers

User login

Frontpage Sponsor

Main

Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
35%
Installation Wizard into new VRC
42%
Manual into existing VRC
3%
Manual into new VRC
19%
Total votes: 31

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 19th April 2004, 16:57
fbernaus's Avatar
fbernaus fbernaus is offline
Junior Member
 
Join Date: Jun 2002
Location: Azpeitia - Spain
Posts: 27
fbernaus is on a distinguished road
Baan: Baan IVc4 - DB: Oracle 8.0.3 - OS: HP-UX 11.0, NT 4.0
CreateObject

Hello,

Somebody can help me in this? Do you know if there is a way to pass in the CreateObject(ProgId of Class for using AFS) the password with I want to connect to the session? That it is, I would like a way in which I could pass the parameters for the connection to the server. Any idea would be helpful.

Thanks very much,
Best regards
Reply With Quote
Sponsored Links
  #2  
Old 21st April 2004, 16:56
Al Smith Al Smith is offline
Member
 
Join Date: Mar 2002
Location: Marcellus, MI. USA
Posts: 52
Al Smith is on a distinguished road
Baan: Baan IVc4 - DB: Oracle - OS: Unix, NT, W2k
Here's something I put together a couple of years ago. I added some comments to try to explain what it's doing.
It's rather complicated and could use some cleaning up but maybe it will give you some ideas.
What it does is automatically send the Username and Password to the Logon window then clicks the OK button.
Code:
Option Explicit
Dim BaanObj As Baan4.Baan4
Dim lHwnd() As Long
Public winnum As Integer

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lparam As Any) As Long

Declare Function EnumChildWindows Lib "user32" _
(ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lparam As Long) As Long

Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, ByVal lparam As Long) As Long

Const WM_SETTEXT = &HC
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202

'--------------------------------------------------------------------------

Function EnumChildProc(ByVal hWnd As Long, ByVal lparam As Long) As Long
'The winnum variable counts the Child Processes in the Login Window
'and sets the index for the lHwnd(winnum) array. This array is the
'Windows Handle for the Child processes.
   winnum = winnum + 1
   ReDim Preserve lHwnd(winnum)
   lHwnd(winnum) = hWnd
   EnumChildProc = 1
End Function

'--------------------------------------------------------------------------

Sub Main()
   Start_Baan
   Find_Password_Window
   WaitForBaan
   OleOperations
End Sub

'--------------------------------------------------------------------------

Sub Start_Baan()
'testbox.bwc config - No username, No Password, Command = /Automation
   Call ShellExecute(0&, "Open", "c:\baan\lib\user\testbox.bwc", vbNullString, vbNullString, 1)
End Sub

'--------------------------------------------------------------------------

Sub Find_Password_Window()
   Dim retval As Long
   ReDim lHwnd(1)
'Wait for Login window to appear. The title of the window, e.g. "Login for sstest",
'must match exactly and is Case sensitive.
   Do Until lHwnd(0) <> 0
      lHwnd(0) = FindWindowEx(0, 0, vbNullString, "Login for sstest")
      DoEvents
   Loop
'We have to wait for the Login window to fully form.
'It will have 9 child processes when fully formed.
'The Child Processes are detected by the Function EnumChildProc above.
'If the functions returns prematurely, the winnum variable is set to 0
'and the Child Processes are counted again.
DoAgain:
   retval = EnumChildWindows(lHwnd(0), AddressOf EnumChildProc, 0)
   If winnum <> 9 Then
      winnum = 0
      GoTo DoAgain
   End If
   DoEvents
'Sub to send the Username to the Login window's Username box.
   Enter_Username
'Sub to send the Password to the Login window's Password box.
   Enter_Password
'Sub to simulate a mouse click on the OK button in the Login window.
   Click_OK
End Sub

'--------------------------------------------------------------------------

Sub Enter_Username()
'Send the Username to the Login window's Username box.
   Dim sText As String
   sText = "YourUserName"
   Call SendMessage(lHwnd(9), WM_SETTEXT, Len(sText), ByVal sText)
   DoEvents
End Sub

'--------------------------------------------------------------------------

Sub Enter_Password()
'Send the Password to the Login window's Password box.
   Dim sText As String
   sText = "YourPassword"
   Call SendMessage(lHwnd(2), WM_SETTEXT, Len(sText), ByVal sText)
   DoEvents
End Sub

'--------------------------------------------------------------------------

Sub Click_OK()
'Simulate a mouse click on the OK button in the Login window.
   Call PostMessage(lHwnd(3), WM_LBUTTONDOWN, 0, 0)
   Call PostMessage(lHwnd(3), WM_LBUTTONUP, 0, 0)
End Sub

'--------------------------------------------------------------------------

Sub WaitForBaan()
   Dim w As Long
   Dim start As Long
   Do While w = 0
      w = FindWindow(vbNullString, "Option Dialog")
   Loop
'I wish I could eliminate this but:
'Wait 5 seconds for Baan to fully initialize.
'After Baan is initialized, the CreateObject will use
'the current Baan session for BaanObj.
'If Baan is not fully initialized the CreateObject
'will try to start a new session.
   start = Timer
   Do Until Timer > start + 5
   Loop
End Sub

'--------------------------------------------------------------------------

Sub OleOperations()
   Set BaanObj = CreateObject("Baan4.Application")
   BaanObj.ParseExecFunction "ottstpapihand", "stpapi.find(" & Chr(34) & "tiitm0101m000" & Chr(34) & ")"
   Debug.Print BaanObj.ReturnValue
   BaanObj.ParseExecFunction "ottstpapihand", "stpapi.end.session(" & Chr(34) & "tiitm0101m000" & Chr(34) & ")"
   BaanObj.Quit
End Sub
__________________
A computer is a tool, not a toy.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +2. The time now is 10:01.


©2001-2017 - Baanboard.com - Baanforums.com