News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Number and type of arguments required for call to C library

Started by jj2007, May 21, 2014, 10:21:19 PM

Previous topic - Next topic

dedndave

hi adeyblue  :t

well - i get up to the point where i have to assign one of the ID'ed namespaces to an object
then, it gets a little fuzzy - lol
it looks easy in C, but
1) there is a lot of material to read about Shell.Application
2) i can't really find the specific docs i am looking for

GoneFishing

Dave,
Now I can do drag'n'drop on zips too ... so the Windows XP knows how to do it  BUT WHY WE DON'T?
Adeyblue's approach is a bit complicated to try it in MASM

dedndave

well - the idea seems simple enough

i don't know what language this is - python or something - lol

Set sa = CreateObject("Shell.Application")
Set zip= sa.NameSpace(zipFile)
Set Fol=sa.NameSpace(FolderToZip)
zip.CopyHere(Fol.Items)


but - setting a folder is a 2 step process
1) get the id
2) set the property (i guess it's a property)

i can get the id, fine
and - CopyHere seems easy
it's that "set the folder" part that i don't understand
it seems to be done with IDispatch::Invoke

i wish i had a working C++ source and EXE to look at   :(

dedndave

in fact, i think this would work

CoCreateInstance
IDispatch::GetIDsOfNames          ;source folder
IDispatch::Invoke                 ;set source folder - this is the part i can't get going
IDispatch::GetIDsOfNames          ;target folder
IDispatch::CopyHere(idTarget)
IDispatch::Release

GoneFishing

Yes , it's simple : 3 lines of code in powershell
That's why I've implemented it in MASM and it worked JUST FINE on my machine .
The code you posted looks like VisualBasic script  and you may try to run it with WSCRIPT
Here is a link to an advanced VBasic Script:
http://stackoverflow.com/questions/30211/can-windows-built-in-zip-compression-be-scripted
I'll try it on my Windows XP . I want to know if this simple method works in VBasic Script and powershell on XP .

dedndave

scripts don't help us, much
i need a working C++ source and EXE   :t

GoneFishing

Quote from: dedndave on May 27, 2014, 04:12:15 AM
in fact, i think this would work

CoCreateInstance
IDispatch::GetIDsOfNames          ;source folder
IDispatch::Invoke                 ;set source folder - this is the part i can't get going
IDispatch::GetIDsOfNames          ;target folder
IDispatch::CopyHere(idTarget)
IDispatch::Release


You're wrong , Dave
The first call to GetIDsOfNames obtains Namespace member and IT'S THE TARGET FOLDER
My code is alright except that I don't call  Release method

[EDIT]: Oh, I understood now - we're obtaining folder interface for both source and target . Worth a try . Usually I try  scripts first .


GoneFishing

Quote from: dedndave on May 27, 2014, 04:14:58 AM
scripts don't help us, much
i need a working C++ source and EXE   :t
They can help us  - if we will know that this "simple method"  works in scripts on XP  then we may be sure that the reason is in my code and not in OS

dedndave

well - that may not be the way your example works
but, it seems logical - and i seem to recall seeing code like that browsing around the web

dedndave

the point of having an EXE (with source helps) is that we can see the generated code
we can't do that with scripts

GoneFishing

#55
...

dedndave

thanks   :t

this is my code, so far
if i get it working, i will add error reports (or sooner, if needed - lol)
and, i even have a way to wait for it to finish writing the zip   :biggrin:

notice, i used different paths for the test files

                  CLSIDFromProgID: Success
                 CoCreateInstance: Success
IDispatch::GetIDsOfNames(Source): Success
               IDispatch::Release: Success

Press any key to continue ...

GoneFishing

Dave , could you post  the essential parts of your code  in "CODE" tags , please - I don't have an opportunity to download files here  :(

adeyblue

If you still need it, here's a C++ exe and src. It uses IShellDispatch and the Folder interfaces directly since basic IDispatch and me aren't friends. I'll rework it to use those if you need to see what that looks like.

dedndave

thanks, adeyblue   :t

vertograd...
the biggest difference between my code and yours is that i use qWord's METHOD macro
it simplifies the IDispatch calls   :biggrin:

;***********************************************************************************************

;METHOD macro by qWord

METHOD  MACRO   name,args:VARARG
        LOCAL   _type1,_type2
        _type1  TYPEDEF PROTO args
        _type2  TYPEDEF PTR _type1
        EXITM   <name _type2 ?>
        ENDM

;###############################################################################################

;IDispatch Interface

IDispatch STRUCT
  METHOD(QueryInterface,   _this:LPVOID,riid:LPVOID,ppvObj:LPVOID)
  METHOD(AddRef,           _this:LPVOID)
  METHOD(Release,          _this:LPVOID)
  METHOD(GetTypeInfoCount, _this:LPVOID,pctinfo:UINT)
  METHOD(GetTypeInfo,      _this:LPVOID,iTInfo:UINT,lcid:LCID,ppTInfo:LPVOID)
  METHOD(GetIDsOfNames,    _this:LPVOID,riid:LPVOID,rgszNames:LPOLESTR,cNames:UINT,lcid:LCID,rgDispId:LPVOID)
  METHOD(dInvoke,          _this:LPVOID,dispIdMember:DWORD,riid:LPVOID,lcid:LCID,wFlags:DWORD,pDispParams:LPVOID,pVarResult:LPVOID,pExcepInfo:LPVOID,puArgErr:UINT)
IDispatch ENDS


then, the calls are easy...
    print   offset sz0001
    INVOKE  CLSIDFromProgID,offset szShell,offset pClsId
    .if eax==S_OK
        print   offset szSuccess
        print   offset sz0002
        INVOKE  CoCreateInstance,offset pClsId,NULL,CLSCTX_INPROC_SERVER,offset IID_IDispatch,offset pvShell
        .if eax==S_OK
            print   offset szSuccess
            print   offset sz0003
            mov     edx,pvShell
            mov     ecx,[edx]
            INVOKE  IDispatch.GetIDsOfNames[ecx],edx,offset IID_NULL,offset adwObjSource,1,409h,offset adwDispIdSource
            .if eax==S_OK
                print   offset szSuccess

       ;         print   offset sz0004





            .endif
            print   offset sz0009
            mov     edx,pvShell
            mov     ecx,[edx]
            INVOKE  IDispatch.Release[ecx],edx
            .if eax==S_OK
                print   offset szSuccess
            .endif
        .endif
    .endif