Article View: borland.public.cppbuilder.nativeapi
Article #8823Access Violation on LoadLibrary
From: Analyzer
Date: Tue, 21 Sep 2004 06:48
Date: Tue, 21 Sep 2004 06:48
81 lines
2840 bytes
2840 bytes
Hi there,
I'm dealing with a DLL and i'm getting Access Violation Errors continously.What is wrong with my code?
Analyzer
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "main.h"
#include "hllapi.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
typedef WORD WINAPI(*THllapiEntry) (int *, char *, int *, int *);
HWND DllHandle = LoadLibrary("PCSHLL32");
THllapiEntry EntryPoint = (THllapiEntry)GetProcAddress( DllHandle, "HLLAPI" );
bool FConnected;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
int Func;
int Alen;
int RetC;
AnsiString ShortName = "A";
Func = CONNECTPS;
Alen = 1;
RetC = 0;
EntryPoint( &Func, ShortName.c_str(), &Alen, &RetC );
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
AnsiString Txt;
int FRows,FCols;
FRows = 80;FCols = 25;
Txt.SetLength( FRows * FCols );
int Func = COPYPS;
int Alen = FRows * FCols;
int RetC = 0;
EntryPoint( &Func, Txt.c_str(), &Alen, &RetC);
ShowMessage("*"+Txt+"*");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
int Func = DISCONNECTPS;
int Alen = 1;
RetC = 0;
EntryPoint( &Func, ShortName.c_str(), &Alen, &RetC );
FConnected = false;
Func = RESETSYSTEM;
Alen = 0;
RetC = 0;
EntryPoint( &Func, NULL, &Alen, &RetC );
FreeLibrary( DllHandle );
}
//---------------------------------------------------------------------------
Technical Details
Message-ID:
<414fceb0$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news.zanker.org!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,96780444f192a93f,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Analyzer" <Analyzer@nospam.com> Sender: "Analyzer" <Analyzer@nospam.com> Reply-To: "Analyzer" <Analyzer@nospam.com> Subject: Access Violation on LoadLibrary Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 195.175.37.55 X-Forwarded-For: 81.215.251.253 NNTP-Posting-Host: 207.105.83.66 Message-ID: <414fceb0$1@newsgroups.borland.com> Date: 20 Sep 2004 23:48:16 -0700 X-Trace: newsgroups.borland.com 1095749296 207.105.83.66 (20 Sep 2004 23:48:16 -0700) Lines: 82 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news.zanker.org!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail