Interface Generator 1.0 - Get it!

Share your advanced PureBasic knowledge/code with the community.
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Interface Generator 1.0 - Get it!

Post by aXend »

Hello to you all!

I finally made it! The Interface Generator is finished. I only hope that you don't find to much bugs in it. :wink:
You can download the program and the documentation from
http://home.planet.nl/~aXend/purebasic/ ... erator.zip

I'm anxious to get your experiences and comments. Happy coding :!:
User avatar
bingo
Enthusiast
Enthusiast
Posts: 210
Joined: Fri Apr 02, 2004 12:21 pm
Location: germany/thueringen
Contact:

Post by bingo »

great :!:

any hints to handling the variables ?

Code: Select all

; DispInterfaces

Interface ITextStream Extends IDispatch
  get_Line(a)
  get_Column(a)
  get_AtEndOfStream(a)
  get_AtEndOfLine(a)
  Read(a,b)
  ReadLine(a)
  ReadAll(a)
  Write(a)
  WriteLine(a)
  WriteBlankLines(a)
  Skip(a)
  SkipLine()
  Close()
EndInterface

Interface IWshShell Extends IDispatch
  get_SpecialFolders(a)
  get_Environment(a,b)
  Run(a,b,c,d)
  Popup(a,b,c,d,e)
  CreateShortcut(a,b)
  ExpandEnvironmentStrings(a,b)
  RegRead(a,b)
  RegWrite(a,b,c)
  RegDelete(a)
EndInterface

Interface IWshCollection Extends IDispatch
  Item(a,b)
  Count(a)
  get_length(a)
  _NewEnum(a)
EndInterface

Interface IWshEnvironment Extends IDispatch
  get_Item(a,b)
  put_Item(a,b)
  Count(a)
  get_length(a)
  _NewEnum(a)
  Remove(a)
EndInterface

Interface IWshShell2 Extends IWshShell
  LogEvent(a,b,c,d)
  AppActivate(a,b,c)
  SendKeys(a,b)
EndInterface

Interface IWshShell3 Extends IWshShell2
  Exec(a,b)
  get_CurrentDirectory(a)
  put_CurrentDirectory(a)
EndInterface

Interface IWshExec Extends IDispatch
  get_Status(a)
  get_StdIn(a)
  get_StdOut(a)
  get_StdErr(a)
  get_ProcessID(a)
  get_ExitCode(a)
  Terminate()
EndInterface

Interface IWshShortcut Extends IDispatch
  get_FullName(a)
  get_Arguments(a)
  put_Arguments(a)
  get_Description(a)
  put_Description(a)
  get_Hotkey(a)
  put_Hotkey(a)
  get_IconLocation(a)
  put_IconLocation(a)
  put_RelativePath(a)
  get_TargetPath(a)
  put_TargetPath(a)
  get_WindowStyle(a)
  put_WindowStyle(a)
  get_WorkingDirectory(a)
  put_WorkingDirectory(a)
  Load(a)
  Save()
EndInterface

Interface IWshNetwork Extends IDispatch
  get_UserDomain(a)
  get_UserName(a)
  get_UserProfile(a)
  get_ComputerName(a)
  get_Organization(a)
  get_Site(a)
  MapNetworkDrive(a,b,c,d,e)
  RemoveNetworkDrive(a,b,c)
  EnumNetworkDrives(a)
  AddPrinterConnection(a,b,c,d,e)
  RemovePrinterConnection(a,b,c)
  EnumPrinterConnections(a)
  SetDefaultPrinter(a)
EndInterface

Interface IWshNetwork2 Extends IWshNetwork
  AddWindowsPrinterConnection(a,b,c)
EndInterface

Interface IWshURLShortcut Extends IDispatch
  get_FullName(a)
  get_TargetPath(a)
  put_TargetPath(a)
  Load(a)
  Save()
EndInterface

Interface IFileSystem Extends IDispatch
  get_Drives(a)
  BuildPath(a,b,c)
  GetDriveName(a,b)
  GetParentFolderName(a,b)
  GetFileName(a,b)
  GetBaseName(a,b)
  GetExtensionName(a,b)
  GetAbsolutePathName(a,b)
  GetTempName(a)
  DriveExists(a,b)
  FileExists(a,b)
  FolderExists(a,b)
  GetDrive(a,b)
  GetFile(a,b)
  GetFolder(a,b)
  GetSpecialFolder(a,b)
  DeleteFile(a,b)
  DeleteFolder(a,b)
  MoveFile(a,b)
  MoveFolder(a,b)
  CopyFile(a,b,c)
  CopyFolder(a,b,c)
  CreateFolder(a,b)
  CreateTextFile(a,b,c,d)
  OpenTextFile(a,b,c,d,e)
EndInterface

Interface IDriveCollection Extends IDispatch
  get_Item(a,b,c,d,e)
  get__NewEnum(a)
  get_Count(a)
EndInterface

Interface IDrive Extends IDispatch
  get_Path(a)
  get_DriveLetter(a)
  get_ShareName(a)
  get_DriveType(a)
  get_RootFolder(a)
  get_AvailableSpace(a)
  get_FreeSpace(a)
  get_TotalSize(a)
  get_VolumeName(a)
  put_VolumeName(a)
  get_FileSystem(a)
  get_SerialNumber(a)
  get_IsReady(a)
EndInterface

Interface IFolder Extends IDispatch
  get_Path(a)
  get_Name(a)
  put_Name(a)
  get_ShortPath(a)
  get_ShortName(a)
  get_Drive(a)
  get_ParentFolder(a)
  get_Attributes(a)
  put_Attributes(a)
  get_DateCreated(a)
  get_DateLastModified(a)
  get_DateLastAccessed(a)
  get_Type(a)
  Delete(a)
  Copy(a,b)
  Move(a)
  get_IsRootFolder(a)
  get_Size(a)
  get_SubFolders(a)
  get_Files(a)
  CreateTextFile(a,b,c,d)
EndInterface

Interface IFolderCollection Extends IDispatch
  Add(a,b)
  get_Item(a,b,c,d,e)
  get__NewEnum(a)
  get_Count(a)
EndInterface

Interface IFileCollection Extends IDispatch
  get_Item(a,b,c,d,e)
  get__NewEnum(a)
  get_Count(a)
EndInterface

Interface IFile Extends IDispatch
  get_Path(a)
  get_Name(a)
  put_Name(a)
  get_ShortPath(a)
  get_ShortName(a)
  get_Drive(a)
  get_ParentFolder(a)
  get_Attributes(a)
  put_Attributes(a)
  get_DateCreated(a)
  get_DateLastModified(a)
  get_DateLastAccessed(a)
  get_Size(a)
  get_Type(a)
  Delete(a)
  Copy(a,b)
  Move(a)
  OpenAsTextStream(a,b,c)
EndInterface

Interface IFileSystem3 Extends IFileSystem
  GetStandardStream(a,b,c)
  GetFileVersion(a,b)
EndInterface

wsh.IWshShell = CreateObject("WScript.Shell")

info.s = "test"

;wsh\Popup(???)

ReleaseObject(wsh) 
http://www.bratbaecker.de/vee/activ/wshom_ocx_2.htm
["1:0>1"]
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

Great!

Maybe a simple progid enum thingy?
Like changing the textbox to a combo + edit box version?
PolyVector
Enthusiast
Enthusiast
Posts: 499
Joined: Wed Sep 17, 2003 9:17 pm
Location: Southern California
Contact:

Post by PolyVector »

Nice work aXend!!!
This is the most usefull tool in my collection now :)
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Axend,

This is great! I can't wait to the weekend, when I'll get to have a good play.
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

@bingo:
any hints to handling the variables ?
If you look at the left side panel and click on DispInterfaces, then on the name of a specific interface and then on the name of a method, you get all the information about the parameters. You can read this in the documentation.

If you click on DispInterfaces, then on WShell and then on Popup you get:

Code: Select all

[VOffset($28)] HRESULT Popup([in] BSTR Text,
     [in, optional] VARIANT* SecondsToWait,
     [in, optional] VARIANT* Title,
     [in, optional] VARIANT* Type,
     [out, retval] int* out_Button)
This shows exactly how to call this method.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

WOW. This is incredible. REALLY makes all that XML stuff easy as pie!

Thank you thank you thank you!

Get with Fred to put this in the PB distribution - it is invaluable.
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

It's very import to understand how to code a VARIANT parameter. This is not the same as a VARIANT* parameter. The last one can be coded with a pointer to the structure like parm.VARIANT.

The first one requires 16 bytes as a parameter. PureBasic can't handle that. In the VARIANT_inc.pb I included a structure pToVariant. So you can code (as an example)

Code: Select all

parm.VARIANT\vt = #VT_BSTR
parm\bstrVal = Ansi2Uni("a string")
*pointer.pToVariant = parm
; call the method
object\method([....,]*pointer\a,*pointer\b,*pointer\c,*pointer\d[,....])
If you have any question on this let me know!
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

Here an example of how to use the output of Interface Generator with WScript.Shell.

Type the ProgID "WScript.Shell" in Interface Generator and save the output to a file. I changed the Enumerations so that all got the prefix "Wsh" to prevend conflicts. (The constant #Hidden seems to exist somewhere???)

Include the file in your program and then you can do the following.

Code: Select all

IncludeFile "WScript_Shell.pb"

Global WshShell.IWshShell3

Global None.VARIANT
None\vt    = #VT_ERROR 
None\scode = #DISP_E_PARAMNOTFOUND 

#InfoIcon = 64

Procedure Send(key.s)
; HRESULT SendKeys([in] BSTR Keys,
;      [in, optional] VARIANT* Wait)
  WshShell\SendKeys(Ansi2Uni(key),None);
EndProcedure

Procedure Run(appl.s,parm.s)
  runapp.s = appl+" "+parm
; HRESULT Run([in] BSTR Command,
;      [in, optional] VARIANT* WindowStyle,
;      [in, optional] VARIANT* WaitOnReturn,
;      [out, retval] int* out_ExitCode)
  WshShell\Run(Ansi2Uni(runapp),None,None,@out);
EndProcedure

Procedure.l Popup(text.s,wait.l,title.s,type.l)
  DefType.VARIANT Vwait, Vtitle, Vtype
  Vwait\vt        = #VT_UI4
  Vwait\iVal      = wait
  Vtitle\vt       = #VT_BSTR
  Vtitle\bstrVal  = Ansi2Uni(title)
  Vtype\vt        = #VT_UI4
  Vtype\iVal      = type
; HRESULT Popup([in] BSTR Text,
;      [in, optional] VARIANT* SecondsToWait,
;      [in, optional] VARIANT* Title,
;      [in, optional] VARIANT* Type,
;      [out, retval] int* out_Button)
  WshShell\Popup(Ansi2Uni(text),Vwait,Vtitle,Vtype,@button.l)
  ProcedureReturn button
EndProcedure

OnErrorGoto(?Error)

WshShell = CreateObject("WScript.Shell");

Run("iexplore","www.purebasic.com")
Delay(3000) ;
Send("{TAB 5}") ; Go to News
Send("{ENTER}") ;
Delay(5000)
Send("%{F4}") ; Alt-F4 Stop
Delay(1000) ;
Popup("This was an example of using WScript.Shell from PureBasic",5,"Demo Program",#InfoIcon)

ReleaseObject(WshShell)

End

;- Error handler
Error:
error.s = Space(500)
error = GetErrorDescription()
errorln.l = GetErrorLineNR()
CRLF.s  = Chr(13)+Chr(10)
msg.s = ""
msg.s = "line " + Str(GetErrorLineNR()) + ": " + error + " (" + Hex(GetErrorNumber()) + " )" + CRLF
MessageRequester("Error", msg, 0)

End
Good luck! :)
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Karbon wrote:Get with Fred to put this in the PB distribution - it is invaluable.
Agreed. Thanks aXend.
Moonshine
Enthusiast
Enthusiast
Posts: 263
Joined: Tue May 25, 2004 12:13 am
Location: UK

Post by Moonshine »

Can this be used to get interfaces from Direct3D 8? Tried opening the DLL in the system32 folder "D3D8.DLL" plus a few others but they dont open. Maybe Im missing the point here, but can anybody help? Cheers.
Mark my words, when you least expect it, your uppance will come...
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

You can use dx8vb.dll. That includes direct3d 8.

The point is that it has to be a typelibrary. Not every dll is that.
Moonshine
Enthusiast
Enthusiast
Posts: 263
Joined: Tue May 25, 2004 12:13 am
Location: UK

Post by Moonshine »

OK, thanks aXend I understand now.
Mark my words, when you least expect it, your uppance will come...
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Excellent work!

I've been messing with VB ActiveX controls and they work just fine :P

Just 1 note:

The file requester should keep the last directory you went to...
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

@Num3 Thanks.
The file requester should keep the last directory you went to...
You are right. :!: I'm aware that I could do something more on the GUI side of the Interface Generator. Use a Menu and/or Toolbar... I thought it would be useful to publish the tool now, so it can be used. I'll work on improvement from now. Any other suggestions?
Post Reply