Walter, that was brilliant! Just what I needed. I had a bit of trouble with
I set up a fresh Win32 project and built the .RES file in that. I eventually
the .rc file and a couple of /I switches to rc.exe. It feels like this
should't be necessary. If you have any idea as to why RC.exe complains
Thanks again.
"Walter Wang [MSFT]" wrote:
> Hi Michael,
>
> To embed a win32 resource in .NET application, you can following these
> steps:
>
> 1) Suppose we have a file "logo.png" in the project directory, create two
> files "resource.h" and "SplashScreenWin32Resources.rc":
>
> resource.h:
>
> #define IDB_SPLASHSCREEN 101
>
>
> SplashScreenWin32Resources.rc:
>
> #include "resource.h"
>
> IDB_SPLASHSCREEN PNG "Logo.png"
>
>
> Note you don't need to include these three files in the project.
>
> 2) Open your project's properties dialog, in the Build Events tab, input
> following command in the "Pre-Build event command line":
>
> "$(DevEnvDir)..\Tools\Bin\rc.exe" /d "UNICODE"
> "$(ProjectDir)SplashScreenWin32Resources.rc"
>
>
>
> This will compile the .rc file using resource compiler everytime you build
> your project; and the generated file will be SplashScreenWin32Resources.res.
>
>
> 3) Now switch to the first tab "Application" of the project properties
> dialog, in the resource part, select "Resource File" and input
> "SplashScreenWin32Resources.RES" as the file name.
>
> 4) Rebuild your project, it will not contains the win32 resource file.
>
> 5) Use following code to load the resource:
>
> [DllImport("kernel32.dll")]
> static extern IntPtr FindResource(IntPtr hModule, int lpName,
> string lpType);
>
> private void button1_Click(object sender, EventArgs e)
> {
> IntPtr hRes =
> FindResource(Marshal.GetHINSTANCE(this.GetType().Module), 101, "PNG");
> }
>
>
> Hope this helps.
>
>
> Sincerely,
> Walter Wang (wawang@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
>
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > ications. If you are using Outlook Express, please make sure you clear the
> check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
> promptly.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
>
http://msdn.microsoft.com/subscriptions/support/default.aspx. > ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>