(AVIFIL32) new question (see newest post)
Posted: Sun Jan 23, 2011 12:10 am
I have tried and tried to write the code correctly but I guess I just don't understand how to interact with this library.
I've consulted the MSDN, API-Guide, guides in other languages that I've tried to mirror... My first problem was getting it to recognize the required szFile parameter, which is supposed to be a null terminated string containing the path to the file.... It wouldn't compile unless I gave it a pointer (I think I did it right?), because it only accepts numbers and not string input (how retarded???)
So now the code will compile but it gives me an error "Invalid memory access (write error at address 0)"... I have never used pointers so maybe I am doing something wrong.. If anyone could write an example application that opens a file and tells you it did so successfully, I would appreciate it.
For what its worth, here is my horribly n00bish attempt at code .
There is some commented out code and other unused stuff atm because I was just building a quick and dirty GUI with the Visual Designer.. the plan was to have it run the AVI_Open procedure after the window was closed, and then echo a debug output (stupid way to build a trigger I know), just to see if I could get it to run and close without complaining at all.
I've consulted the MSDN, API-Guide, guides in other languages that I've tried to mirror... My first problem was getting it to recognize the required szFile parameter, which is supposed to be a null terminated string containing the path to the file.... It wouldn't compile unless I gave it a pointer (I think I did it right?), because it only accepts numbers and not string input (how retarded???)
So now the code will compile but it gives me an error "Invalid memory access (write error at address 0)"... I have never used pointers so maybe I am doing something wrong.. If anyone could write an example application that opens a file and tells you it did so successfully, I would appreciate it.
For what its worth, here is my horribly n00bish attempt at code .
There is some commented out code and other unused stuff atm because I was just building a quick and dirty GUI with the Visual Designer.. the plan was to have it run the AVI_Open procedure after the window was closed, and then echo a debug output (stupid way to build a trigger I know), just to see if I could get it to run and close without complaining at all.
Code: Select all
; PureBasic Visual Designer v3.95 build 1485 (PB4Code)
;- Window Constants
;
Enumeration
#Window_0
#Lib
EndEnumeration
;- Gadget Constants
;
Enumeration
#Image_0
EndEnumeration
;- Image Plugins
;- Image Globals
Global Image0
Global avifile.s
avifile.s = "C:\Program Files (x86)\AutoIt3\Examples\GUI\sampleAVI.avi"
Global *pAviFile = @avifile
Global hFile.l
OpenLibrary(#Lib, "AVIFIL32.DLL") ;// Open AVIFIL32 DLL and give it the handle #Lib
CallFunction (#Lib, "AVIFileInit") ;// Initialize the library
;- Catch Images
;Image0 = CatchImage(0, ?Image0)
;- Images
;DataSection
;Image0:
; IncludeBinary ""
;EndDataSection
Procedure Open_Window_0()
If OpenWindow(#Window_0, 303, 160, 619, 488, "New window ( 0 )", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
ImageGadget(#Image_0, 140, 50, 350, 310, Image0)
;Repeat this loop to keep the window open until the user closes it
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
EndProcedure
Procedure Open_AVI()
CallFunction(#Lib, "AVIFileOpen", hFile, *pAviFile, #OF_READ, #Null)
CallFunction(#Lib, "AVIFileRelease", hFile)
CallFunction(#Lib, "AVIFileExit")
EndProcedure
Open_Window_0()
Open_AVI()