Resource import:
You can use import ... you can use Import ... / / -------------------------------------------------------------------------------------------- ---------------------------------- Resource usage: / * Due to the SWF format file when importing resources is not VC Standard resources, so you need to specify the resource type "SWF" in the "Resource Type" field, in particular, it must be noted here that quotes must be included. After adding to the resource, you can see the imported SWF resource through the resource view is saved in binary, one but the addition is no longer edited by the resource view. Before using SWF resources, you will first release its dynamic from the application to the file to make further use of resources. You can convert the resource identification number IDR_SWF to string Name by macro makeintresource (), and then look for the resource to memory, loaded to memory, respectively, and load this resource to memory: * / lptstr name = makeintResource (idR_swf); // idR_swf Resource Name. HRSRC RES = FindResource (NULL, NAME, "SWF"); // "SWF" resource type. Hglobal GL = LoadResource (NULL, RES); / * After the resource is loaded into memory, the pointer to the address of the resource memory is returned by locking the resource memory, and the resource is saved from the memory to the disk, as for The operation of the storage is complete by the file function cretefile (), and WriteFile (): * / lpvoid lp = lockResource (GL); / / Returns the pointer to the address of the resource memory. CSTRING FILENAME = "Temp.swf"; // Saved Temporary File Name // CREATE_ALWAYS is a new file for the file does not exist. *** CREATEFILE () Create a file using the current .exe file path. Handle fp = cretefile (filename, generic_write, 0, null); DWORD A; // SizeOfResource Get the size of resource files (! Writefile (FP, LP, SizeOfResource (Null, RES), & A, NULL )) RETURN FALSE; CloseHandle (FP); // Close Handle FreeResource (GL); // Release Memory / * With the above code, you can extract SWF resources from the application and release it into the temporary file temp.swf, after this Only for this temporary file operation, it is independent of the inline resource. * // get the current path and add the file name. TCHAR STRCURDRT [500]; INT NLEN = :: getCurrentDirectory (500, strcurd); if (strcurdrt [Nlen]! = '//') {stracurdRT [Nlen ] = '//'; strcurdrt [Nlen] = '/ 0 ';} strfilename = strcurdrt; strfilename = "TEMP.SWF";
The younger brother did not quoted a function of the release, please laugh:
// Function: Release Inlaid Source // Parameters: // [in] SDLLNAME: Resource DLL full path name /// [in] nresourceId: Resource ID // [in] SOUTPUTFILENAME: Release File name // [in] sextendname : Release the file extension // return value: // Success is true, otherwise, for the fake // Note: // sdllname Using the full path name, if only the file name is available, the default // Find the first under the program path. If This parameter is empty and finds // SOUTPUTFILENAME in your own procedure to have a path. If there is no path, then // is released to the XX.exe file in the same level path. // sextendname just releases the file type when it is released the while // sOutputFileName must have the extension. // when the file is released, the file will be hidden .BOOL CCliGlobal :: AssoilInlaidResource (CString sDllName, UINT nResourceID, CString sOutputFileName, CString sExtendName) {ASSERT (! sOutputFileName.IsEmpty ( )); Assert (! Sextendname.isempty ()); lptstr name = makeintResource (nresourceID); // idR_swf resource name.
Hinstance hiMage = null; // interface library handle // Load bound library if (! Sdllname.isempty ()) {hiMage = loadingLibrary (SDLLNAME); if (Hinstance) Hinstance_ERROR {MessageBox (null, "can not be loaded Enter the " SDLLNAME " file, check if the file exists! " If (res == null) return false; hglobal gl = loadingResource (HIMAGE, RES); if (GL == NULL) RETURN FALSE; LPVOID LP = LockResource (GL); // Returns a pointer to the address of the resource memory.