C++ -> Pure HELP!!!

Just starting out? Need help? Post your questions and find answers here.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

C++ -> Pure HELP!!!

Post by Num3 »

I'm writing a CDR burning program :D
I already make iso images, and now i'm writing the burner part

Here's the problem...

Code: Select all

// get disc info 
// -- parameters:
// -- 1st parm: handle of the window of the calling program
// -- 2nd parm: host adapter Id (usually 0)
// -- 3rd parm: CD-R writer SCSI Id
// -- 4th parm: CD-R writer SCSI LUN (usually 0)
   char* info;
   info = pfnFFDiscInfo ( Application -> Handle, 0, 2, 0 );
   MessageBox ( 0, info, "Disc Information Block:", MB_SYSTEMMODAL );
In pure should be:

Code: Select all

 ...(snip)
  If CallFunctionFast(*aspistart)
    Debug "Aspi Layer - OK"

    Delay(1000) ; Little delay before crashing

    x=CallFunctionFast(*aspiinfo,"", 0,2, 0 )
    Debug x
    
    CallFunctionFast(*aspistop)
    Debug "Aspi Layer - Closed"
  EndIf
  CloseLibrary(0)
EndIf
But the program always crashes when i call *aspiinfo function !

Can anyone help???
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

I think, your cut the examples to heavy:

but, when i read the parameter-List:
i would this

Code: Select all

x=CallFunctionFast(*aspiinfo,"", 0,2, 0 )
debug x
correct to this

Code: Select all

x=CallFunctionFast(*aspiinfo,windowid(), 0,2, 0 )
debug peeks(x)
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Thanks GPI, but that didn't make it work either....

Here's the full code in C++ and Purebasic:

C++

Code: Select all

// GETTING INFO ABOUT THE CD-R DISC INSERTED INTO THE CD-R/CD-RW WRITER DEVICE


// A) PROTOTYPES TO PUT INTO THE HEADER:

   HINSTANCE MMC1DllHandle; 
   bool ( __stdcall *pfnFFAspiStart )( HWND );
   char* ( __stdcall *pfnFFDiscInfo )( HWND, int, int, int );
   void ( __stdcall *pfnFFAspiStop )( void );


// B) SOURCE CODE TO PUT INTO CPP FILE:

// load MMC1DLL.DLL
   MMC1DllHandle = LoadLibrary ( "MMC1DLL.DLL" );
   if ( MMC1DllHandle == 0 )
      {
        MessageBox ( NULL, "LoadLibrary:\nMMC1DLL.DLL not found.",
                           "Error FS 001", MB_SYSTEMMODAL );
        return;
      }

// load FFAspiStart address
   pfnFFAspiStart = ( bool ( __stdcall *)( HWND ) )
      GetProcAddress ( MMC1DllHandle, "FFAspiStart" );
   if ( pfnFFAspiStart == NULL )
      {
        MessageBox ( NULL, "GetProcAddress:\nFFAspiStart not found.",
                           "Error FS 002", MB_SYSTEMMODAL );
        return;
      }

// load FFDiscInfo address
   pfnFFDiscInfo = ( char* ( __stdcall *)( HWND, int, int, int ) )
      GetProcAddress ( MMC1DllHandle, "FFDiscInfo" );
   if ( pfnFFDiscInfo == NULL )
      {
        MessageBox ( NULL, "GetProcAddress:\nFFDiscInfo not found.",
                           "Error FS 003", MB_SYSTEMMODAL );
        return;
      }

// load FFAspiStop address
   pfnFFAspiStop = ( void ( __stdcall *)( void ) )
      GetProcAddress ( MMC1DllHandle, "FFAspiStop" );
   if ( pfnFFAspiStop == NULL )
      {
        MessageBox ( NULL, "GetProcAddress:\nFFAspiStop not found.",
                           "Error FS 004", MB_SYSTEMMODAL );
        return;
      }

// check ASPI support
   if ( pfnFFAspiStart ( Application -> Handle ) == false )
      {
        MessageBox ( NULL, "No ASPI support.",
                           "Error FS 005", MB_SYSTEMMODAL );
        return;
      }

// get disc info 
// -- parameters:
// -- 1st parm: handle of the window of the calling program
// -- 2nd parm: host adapter Id (usually 0)
// -- 3rd parm: CD-R writer SCSI Id
// -- 4th parm: CD-R writer SCSI LUN (usually 0)
   char* info;
   info = pfnFFDiscInfo ( Application -> Handle, 0, 2, 0 );
   MessageBox ( 0, info, "Disc Information Block:", MB_SYSTEMMODAL );

// stop ASPI support
   pfnFFAspiStop ( );

// unload the DLL
   FreeLibrary ( MMC1DllHandle );

PureBasic:

Code: Select all

If OpenLibrary(0,"mmc.dll")
  *aspistart.l=IsFunction(0,"FFAspiStart")
  *aspistop.l=IsFunction(0,"FFAspiStop")
  *aspiinfo.l=IsFunction(0,"FFDiskInfo")
  
  Debug "Loaded"
  
OpenWindow(0,10,10,320,200,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Drive Check")
  
  If CallFunctionFast(*aspistart)
    Debug "Aspi Layer - OK"
    Delay(100)
    txt.s="Drive Check"
    x=CallFunctionFast(*aspiinfo,WindowID(), 0,2, 0 )
    Debug x
    
    CallFunctionFast(*aspistop)
    Debug "Aspi Layer - Closed"
  EndIf
  CloseLibrary(0)
EndIf
Post Reply