Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Extract resources from a DLL
Message
De
01/02/2013 22:36:35
 
 
À
01/02/2013 10:25:47
Emerson Reed
Folhamatic Tecnologia Em Sistemas
Americana - São Paulo, Brésil
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 7
Application:
Desktop
Divers
Thread ID:
01564921
Message ID:
01564983
Vues:
54
Assuming you are the creator of the DLL and it is in VFP, you can create a files.DBF, add a memo field, and a name field.

FileToStr() the file into the memo field and save its name.

Then build the DBF into the DLL. Very important.

When the DLL runs, look for your files on disk. If not there, USE files.DBF and StrToFile() the memo fields.


>Hi Folks.
>I have a DLL with embedded resources (PNG and INI files) that I need to enumerate and save as standalone files.
>I'm already enumerating the resources, but I don't know how to save them.
>Someone could help me to accomplish this?
>Here is the code...
>
>Local lcFolder
>m.lcFolder = Justpath(Sys(16))
>Set Default To (m.lcFolder)
>
>* Init Vfp2c32
>Set Library To vfp2c32
>
>#INCLUDE vfp2c.h
>If !InitVFP2C32(VFP2C_INIT_ALL)
>   Local laError[1], lnCount, xj, lcError
>   lnCount = AERROREX('laError')
>   lcError = 'VFP2C32 Library initialization failed:' + Chr(13)
>   For xj = 1 To lnCount
>      lcError = lcError + ;
>         'Error No : ' + Transform(laError[1]) + Chr(13) + ;
>         'Function : ' + laError[2] + Chr(13) + ;
>         'Message : "' + laError[3] + '"'
>   Endfor
>   && show/log error and abort program initialization ..
>   Messagebox(m.lcError,16,"Error")
>   Return
>Endif
>
>#Define LOAD_LIBRARY_AS_IMAGE_RESOURCE 0x00000020
>#Define LOAD_LIBRARY_AS_DATAFILE       0x00000002
>
>* http://msdn.microsoft.com/en-us/library/windows/desktop/ms684179%28v=vs.85%29.aspx
>Declare Integer LoadLibraryEx In Win32api ;
>   String lpFileName, ;
>   Integer hFile, ;
>   Integer dwFlags
>
>* http://msdn.microsoft.com/en-us/library/windows/desktop/ms683152%28v=vs.85%29.aspx
>Declare Integer FreeLibrary In Win32api ;
>   Long hModule
>
>Local lcResourceFile, lnhModule
>m.lcResourceFile = Addbs(m.lcFolder) + "Office2007.dll"
>
>m.lnhModule = LoadLibraryEx(m.lcResourceFile, 0, LOAD_LIBRARY_AS_IMAGE_RESOURCE + LOAD_LIBRARY_AS_DATAFILE)
>If m.lnhModule > 0
>
>   *
>   Local lcResources, laResourceTypes[1], lnResourceType, laResources[1], lnResource
>   m.lcResources = ""
>   If AResourceTypes("laResourceTypes", m.lnhModule) > 0
>      For m.lnResourceType=1 To Alen(m.laResourceTypes)
>         m.lcResources = m.lcResources + Chr(13) + Chr(10) + ;
>            "Resource type: " + ;
>            Alltrim(Transform(m.laResourceTypes[m.lnResourceType])) + ;
>            Chr(13) + Chr(10)
>         If AResourceNames("laResources", m.lnhModule, m.laResourceTypes[m.lnResourceType]) > 0
>            For m.lnResource=1 To Alen(m.laResources)
>               m.lcResources = m.lcResources + ;
>                  "Resource name: " + ;
>                  Alltrim(Transform(m.laResources[lnResource])) + ;
>                  Chr(13) + Chr(10)
>               * Save each resource here...
>            Endfor
>         Endif
>      Endfor
>      _Cliptext = m.lcResources
>   Endif
>   *
>
>   If FreeLibrary(m.lnhModule) <> 0
>   Else
>      ? "Error releasing library..."
>   Endif
>Else
>   ? "Error loading library..."
>Endif
>
>Release Library vfp2c32
>
>Clear Dlls LoadLibraryEx
>Clear Dlls FreeLibrary
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform