Announcement

Collapse
No announcement yet.

How to hide DOS-app under NT

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Florent Heyworth
    replied
    With pleasure

    Cheers

    Florent

    ------------------

    Leave a comment:


  • Semen Matusovski
    replied
    Florent --
    I should you a wagon of beer.


    [This message has been edited by Semen Matusovski (edited April 28, 2000).]

    Leave a comment:


  • Florent Heyworth
    replied
    Hi Semen

    the following works - you needed a BYVAL for the Reserved parameter as well as BYVALs for the callback function:

    Code:
    #COMPILE EXE
    #REGISTER NONE
    #DIM ALL
    #INCLUDE "Win32Api.Inc"
    
    TYPE FILE_IN_CABINET_INFO
        NameInCabinet AS ASCIIZ PTR
        FileSize AS DWORD
        Win32Error AS DWORD
        DosDate AS WORD
        DosTime AS WORD
        DosAttribs AS WORD
        FullTargetName AS ASCIIZ * %MAX_PATH
    END TYPE
    
    DECLARE FUNCTION SetupIterateCabinet LIB "SetupApi.Dll" ALIAS "SetupIterateCabinetA" _
    (szCabinetFile AS ASCIIZ, BYVAL Reserved AS DWORD, BYVAL MsgHandler AS LONG, BYVAL hContext AS LONG) AS LONG
    
    FUNCTION CabinetCallback (BYVAL pMyInstallData AS LONG, _
    BYVAL Notification AS DWORD, BYVAL Param1 AS DWORD, BYVAL Param2 AS DWORD) AS LONG
    
    
        %SPFILENOTIFY_FILEINCABINET  = &H00000011
        %SPFILENOTIFY_FILEEXTRACTED  = &H00000013
    
        DIM RetVal AS LONG
        DIM szTarget AS ASCIIZ * %MAX_PATH
        DIM pInfo AS FILE_IN_CABINET_INFO PTR
    
        RetVal = 0 ' NO_ERROR
        SELECT CASE Notification
            CASE %SPFILENOTIFY_FILEINCABINET
                pInfo = Param1
                MSGBOX @[email protected]
                @pInfo.FullTargetName = @[email protected]
                FUNCTION = 1 ' FILEOP_DOIT (Extract the file)
             CASE %SPFILENOTIFY_FILEEXTRACTED:
                'pFilePaths = (FILEPATHS *)Param1;
                'printf ( "Extracted %s\n",pFilePaths->Target);
        END SELECT
        FUNCTION = RetVal
    END FUNCTION
    
    FUNCTION PBMAIN
        
        
        MSGBOX STR$(SetupIterateCabinet ( "C:\winnt\help\common\alpha.Cab", 0&, CODEPTR(CabinetCallback), 0) )
        MSGBOX STR$(GetLastError)
    
    END FUNCTION
    ------------------

    Leave a comment:


  • Semen Matusovski
    replied
    Eric --
    I tried this variant. But any attempt ByVal for second parameter - GPF.
    In documentation:
    If the function succeeds, the return value is TRUE.
    If the function fails, the return value is FALSE. To get extended error information, call GetLastError.

    I have 0 twice. And I tested in different OSes (95b & 2000).
    Can't understand, where I'm wrong.
    Code:
         #Compile Exe
         #Register None
         #Dim All
         #Include "Win32Api.Inc"
    
         Type FILE_IN_CABINET_INFO
            NameInCabinet As Asciiz Ptr
            FileSize As Dword
            Win32Error As Dword
            DosDate As Word
            DosTime As Word
            DosAttribs As Word
            FullTargetName As Asciiz * %MAX_PATH
        End Type
    
        Declare Function SetupIterateCabinet Lib "SetupApi.Dll" Alias "SetupIterateCabinetA" _
           (CabinetFile As Asciiz, Reserved As Dword, ByVal MsgHandler As Long, ByVal hContext As Long) As Long
    
        Function CabinetCallback (pMyInstallData As Long, _
           Notification As Dword, Param1 As Dword, Param2 As Dword) As Long
    
    
           %SPFILENOTIFY_FILEINCABINET  = &H00000011
           %SPFILENOTIFY_FILEEXTRACTED  = &H00000013
    
           Dim RetVal As Long
           Dim szTarget As Asciiz * %MAX_PATH
           Dim pInfo As FILE_IN_CABINET_INFO Ptr
    
           RetVal = 0 ' NO_ERROR
           Select Case Notification
              Case %SPFILENOTIFY_FILEINCABINET
                pInfo = Param1
                MsgBox @[email protected]
                @pInfo.FullTargetName = @[email protected]
                Function = 1 ' FILEOP_DOIT (Extract the file)
             Case %SPFILENOTIFY_FILEEXTRACTED:
                'pFilePaths = (FILEPATHS *)Param1;
                'printf ( "Extracted %s\n",pFilePaths->Target);
           End Select
           Function = RetVal
        End Function
    
        Function PbMain     
          MsgBox Str$(SetupIterateCabinet ("C:\PbSfx\Polus.Cab", 0, CodePtr(CabinetCallback), 0))
          MsgBox Str$(GetLastError)
       
        End Function
    ------------------


    [This message has been edited by Semen Matusovski (edited April 28, 2000).]

    Leave a comment:


  • Eric Pearson
    replied
    Code:
    PCTSTR CabinetFile, // name of the cabinet file
    DWORD Reserved,     // this parameter is not used
    PSP_FILE_CALLBACK MsgHandler,       // callback routine to use
    PVOID Context       // callback routine context
    Off the top of my head, I would expect that to translate to...

    Code:
    CabinetFile AS ASCIIZ, _
    BYVAL Nothing AS DWORD, _
    BYVAL MsgHandler AS LONG,_   'a CODEPTR value
    BYVAL Context AS LONG
    It may be that the second and/or fourth param must be called with BYVAL 0. (?)

    -- Eric

    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>

    Leave a comment:


  • Semen Matusovski
    replied
    Lance --
    I tried ByVal - GPF.
    May be PCTSTR is not Asciiz ?
    For another functions (translated in Win32Api.Inc As Asciiz) I see LPCTSTR in Win32.Hlp


    ------------------

    Leave a comment:


  • Lance Edmonds
    replied
    James means that the correct translation of that parameter into PB code would mean that the second parameter should be passed BYVAL to the function. Whether you use that parameter or just pass %NULL (0) is up to you, but it is wise to get the declaration correct in the first place.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Semen Matusovski
    replied
    James -
    what do you mean ?
    (I tried with and w/o ByVal, Dword and Long, another name than Nothing; even 3 parameteres only)

    ------------------

    Leave a comment:


  • jcfuller
    replied
    Semen
    BYVAL Nothing AS DWORD ??

    James


    ------------------

    Leave a comment:


  • Semen Matusovski
    replied
    Thanks, Eric. It's exactly, what I need.
    But there is stupid problem.

    I translated
    Code:
    BOOL SetupIterateCabinet(
        PCTSTR CabinetFile,	// name of the cabinet file
        DWORD Reserved,	// this parameter is not used
        PSP_FILE_CALLBACK MsgHandler,	// callback routine to use
        PVOID Context	// callback routine context
       );
    as
    Code:
        Declare Function SetupIterateCabinet Lib "SetupApi.Dll" Alias "SetupIterateCabinetA" _
           (CabinetFile As Asciiz, Nothing As Dword, MsgHandler As Long, hContext As Long) As Long
    and made following function
    Function CabinetCallback (pMyInstallData As Long, _
    Notification As Dword, Param1 As Dword, Param2 As Dword) As Long
    (with ByVal and w/o)

    Try to execute:
    SetupIterateCabinet "C:\PbSfx\Polus.Cab", 0, ByVal CodePtr(CabinetCallback), 0

    Function returns zero. GetLastError also (!). In CallBack function no one message.
    What I am doing wrong ? (I tried different cabinets)
    (probably, in declarations)


    ------------------

    Leave a comment:


  • Eric Pearson
    replied
    Semen --

    IMO, using the DLL would be a much better choice than a hidden DOS app.

    > but I don't understand parameters 3-4 and have
    > no samples. (perhaps, somebody can help ?).

    Here is a Knowledge Base article titled "HOWTO: Use the SetupAPI's SetupIterateCabinet() Function":

    http://support.microsoft.com/support.../Q189/0/85.ASP

    MSDN can supply you with other samples and narratives, too. Just go to...

    http://search.microsoft.com/us/dev/default.asp

    ...make sure you check the "Additional Developer Content" box, and search for "SetupIterateCabinet".

    -- Eric

    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>

    Leave a comment:


  • Semen Matusovski
    replied
    Eric --
    good news. But I'll try to explain more detail.

    I make Self-Exe setup. Header - Pb/Dll module.
    Internals - Cab file with distributive.
    I need to extract files.
    There are some dlls, which can do this work, but they are too big.
    Better to use Setup Api (I guess http://msdn.microsoft.com/library/ps...upapi_61bo.htm
    ), but I don't understand parameters 3-4 and have no samples.
    (perhaps, somebody can help ?).

    I found that extract.exe is 15 Kb only and wanted to use it exactly because of small size. But this is ms-dos app and I have troubles with it's window.

    ------------------

    Leave a comment:


  • Eric Pearson
    replied
    Semen --

    The new version of CWC, which will be released with the new version of Console Tools (probably late next week) now works with DOS programs as well as console apps. So you could use CWC to launch your hidden DOS program. (I think you'll be happy with some of the other improvements we've added to Console Tools. Stay tuned to the Third Party forum for an announcement...)

    But remember that DOS programs can't perform operations like showing themselves, so once you launch a DOS app as hidden, it will stay that way. Unless, that is, you use our new DOSBox Tools product. DOSBox Tools will allow your PB/DOS app to perform its own "ConsoleWindow %SHOW" operation, as well as several other cool things. We expect to release DOSBox Tools in about 2-3 weeks.

    -- Eric


    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>



    [This message has been edited by Eric Pearson (edited April 28, 2000).]

    Leave a comment:


  • Semen Matusovski
    started a topic How to hide DOS-app under NT

    How to hide DOS-app under NT

    I want to start hidden MS-DOS app (not PB/CC module, where it possible to change byte 221).
    Under 9x - question is solved by generating the pif-file.
    But what to do under NT ?
    During execution console window is not visible, because PB dialog has TOPMOST style and covers whole screen.
    But when Shell starts, during short period appears black screen.

    I tried AllocConsole. Black screen disappeared, but it's not possible to close console window by usual way (I mean
    hConsole = GetStdHandle(%STD_OUTPUT_HANDLE) ...
    CloseHandle hConsole: FreeConsole).
    I think, MS-DOS changes owner of window.

    Any ideas ?
Working...
X