🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #7036

Re: EnumResourceNames

#7036
From: jB
Date: Tue, 15 Mar 2005 06:09
117 lines
4420 bytes
Thanks

Here is Full .cpp
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
        if(Edit1->Text.Length()>2)
        OpenDialog1->FileName = Edit1->Text;
        if(OpenDialog1->Execute())
        Edit1->Text = OpenDialog1->FileName;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
        try
        {
                try
                {
                        hResourceDLL = LoadLibrary(Edit1->Text.c_str());
                        EnumResourceNames(hResourceDLL,
                        "RT_ICON",
                        EnumResProc,
                        NULL
                         );
                }
                catch(...)
                {
                        MessageDlg("Cannot Load Library", mtError, 
TMsgDlgButtons() << mbOK, 0);
                }
        }
        __finally
        {
                FreeLibrary (hResourceDLL);
        }

}
//---------------------------------------------------------------------------

BOOL CALLBACK EnumResProc(  HMODULE hModule,   LPTSTR  lpszType,  char * 
lpszName,  long lParam )
{

   if( 0 == strcmp( lpszType, "RT_ICON" ) ||
         0 == strcmp( lpszType,"RT_GROUP_ICON" ) )
   {
                        iTotalIcons++;
   }

    return (true);
}

Here is .h

//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Dialogs.hpp>
//---------------------------------------------------------------------------
BOOL CALLBACK EnumResProc(  HMODULE hModule,   LPTSTR  lpszType,  char * 
lpszName,   long lParam );
        int     iTotalIcons;
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
        TButton *Button1;
        TEdit *Edit1;
        TOpenDialog *OpenDialog1;
        TButton *Button2;
        TEdit *Edit2;
        TLabel *Label1;
        void __fastcall Button1Click(TObject *Sender);
        void __fastcall Button2Click(TObject *Sender);
private: // User declarations
        HMODULE hResourceDLL;
public:  // User declarations
        __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

and the errors

Build
  [C++ Error] Unit1.cpp(37): E2034 Cannot convert 'int (__stdcall *)(void 
*,char *,char *,long)' to 'int (__stdcall *)()'
  [C++ Error] Unit1.cpp(37): E2342 Type mismatch in parameter 'lpEnumFunc' 
(wanted 'int (__stdcall *)()', got 'int (__stdcall *)(void *,char *,char 
*,long)')

Thanks

jB
Technical Details
Message-ID: <42367c11$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!feeder2.on.meganewsservers.com!meganewsservers.com!textfeed1.on.meganewsservers.com!38.119.100.83.MISMATCH!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <4235f905@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,da3abd9f4e77eb05
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "jB" <.>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4235f905@newsgroups.borland.com>
Subject: Re: EnumResourceNames
Date: Tue, 15 Mar 2005 07:09:28 +0100
Lines: 119
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
NNTP-Posting-Host: 212.254.248.110
Message-ID: <42367c11$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1110866961 212.254.248.110 (14 Mar 2005 22:09:21 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!feeder2.on.meganewsservers.com!meganewsservers.com!textfeed1.on.meganewsservers.com!38.119.100.83.MISMATCH!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail