VC program embedded resources

xiaoxiao2021-03-06  17

VC program embedded resources

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";

转载请注明原文地址:https://www.9cbs.com/read-44886.html

New Post(0)