Thread: Writing to custom resources

  1. #1
    Registered User Kirdra's Avatar
    Join Date
    Aug 2002
    Posts
    105

    Writing to custom resources

    Sorry to bother you

    I got a .bin im using as a custom resource file where I am storing 1 byte to save the state of a menu item, I don't want external files.


    Here is what I tried and it didn't work for me...

    Code:
    HGLOBAL hResource = LoadResource(g_hInstance, FindResource(g_hInstance, MAKEINTRESOURCE(IDR_RCDATA_CONFIG), RT_RCDATA));
    
    if(hResource)
    {
    	BYTE* p = (BYTE*)LockResource(hResource);
    
    	if(GetType() == TYPE_COMPLETE)
    		*p = 0;
    	else
    		*p = 1;	
    
    	FreeResource(hResource);
    }
    I was thinking if I get a pointer to it I could modify the data, seems I can only read from it. Please could someone tell me how I can write to my custom resource

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, everything in your .exe should be "read only".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Resources
    By abraham2119 in forum C Programming
    Replies: 5
    Last Post: 04-20-2009, 07:29 PM
  2. Resources in Dev C++
    By JJFMJR in forum Windows Programming
    Replies: 7
    Last Post: 08-27-2007, 05:14 AM
  3. Stl sets and custom classes.
    By cunnus88 in forum C++ Programming
    Replies: 3
    Last Post: 05-12-2006, 11:58 PM
  4. The Art of Writing Comments :: Software Engineering
    By kuphryn in forum C++ Programming
    Replies: 15
    Last Post: 11-23-2002, 05:18 PM
  5. Writing Bitmap Files
    By HappyDude in forum C++ Programming
    Replies: 1
    Last Post: 10-13-2001, 05:48 PM