![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
![]() |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
#1
|
|||
|
|||
|
problema crear dll con clase
Hola, tengo un programa en delphi que usa un .pas que yo mismo he realizado, el cual define una clase y sus métodos. Lo que quiero es crear una dll a partir de ese .pas para en mi programa llamar a esa dll. Gracias de antemano
|
|
#2
|
||||
|
||||
|
Empieza por crear un proyecto de tipo DLL: Delphi File -> new -> (busca por ahí
).después ya podrás pegar el contenido en la dll, o hacer un uses de tu clase, dependiendo de las necesidades. Saludos
__________________
Si usted entendió mi comentario, contácteme y gustosamente, se lo volveré a explicar hasta que no lo entienda, Gracias. |
|
#3
|
||||
|
||||
|
Luego que tengas la dll o bpl exportas las funciones o la clase completa!
En la libreria bpl la clase completa la exportas asi:
En mi caso yo tengo un Form en TForm1 vos pones el nombre de tu clase. |
|
#4
|
||||
|
||||
|
El fichero en cuestión sería:
Una vez hecho y guardado, ve al menú Project|Build All, y te generará el archivo MiDLL.dll NOTA: en MiUnidad.pas las funciones tienen que ir declaradas así:
Saludos. |
|
#5
|
|||
|
|||
|
Pero yo quiero que luego en cualquier programa yo pueda declara un objeto de esa clase y usar sus procedimientos. Mira yo tengo:
Código:
unit MICLASE;
interface
uses
Classes, SysUtils;
const
{ Used with ChannelModeID property }
VORBIS_CM_MONO = 1; { Code for mono mode }
VORBIS_CM_STEREO = 2; { Code for stereo mode }
// Added for multi-channel OGG files
VORBIS_CM_3Ch = 3;
VORBIS_CM_4Ch = 4;
VORBIS_CM_5Ch = 5;
VORBIS_CM_5Dot1Ch = 6;
{ Channel mode names }
VORBIS_MODE: array [0..5] of string = ('Unknown', 'Mono', 'Stereo', '3Ch', '4Ch', '5.1Ch');
type
{ Class TOggVorbis }
TMICLASE = class(TObject)
private
{ Private declarations }
FFileSize: Integer;
FChannelModeID: Byte;
FSampleRate: Word;
FBitRateNominal: Word;
FSamples: Integer;
FID3v2Size: Integer;
FTitle: string;
FArtist: string;
FAlbum: string;
FTrack: Word;
FDate: string;
FGenre: string;
FComment: string;
FVendor: string;
// * Followings are added to show additional stream information by Silhwan Hyun
FStreamVersion : Byte;
FSerialNo : integer;
FExtraTag: string;
procedure FResetData;
function FGetChannelMode: string;
function FGetDuration: Double;
function FGetBitRate: Word;
function FHasID3v2: Boolean;
function FIsValid: Boolean;
public
{ Public declarations }
constructor Create; { Create object }
destructor Destroy; override; { Destroy object }
function ReadFromFile(const FileName: string): Boolean; { Load data }
function SaveTag(const FileName: string): Boolean; { Save tag data }
function ClearTag(const FileName: string): Boolean; { Clear tag data }
property FileSize: Integer read FFileSize; { File size (bytes) }
property ChannelModeID: Byte read FChannelModeID; { Channel mode code }
property ChannelMode: string read FGetChannelMode; { Channel mode name }
property SampleRate: Word read FSampleRate; { Sample rate (hz) }
property BitRateNominal: Word read FBitRateNominal; { Nominal bit rate }
property Title: string read FTitle write FTitle; { Song title }
property Artist: string read FArtist write FArtist; { Artist name }
property Album: string read FAlbum write FAlbum; { Album name }
property Track: Word read FTrack write FTrack; { Track number }
property Date: string read FDate write FDate; { Year }
property Genre: string read FGenre write FGenre; { Genre name }
property Comment: string read FComment write FComment; { Comment }
property Vendor: string read FVendor; { Vendor string }
property Duration: Double read FGetDuration; { Duration (seconds) }
property BitRate: Word read FGetBitRate; { Average bit rate }
property ID3v2: Boolean read FHasID3v2; { True if ID3v2 tag exists }
property Valid: Boolean read FIsValid; { True if file valid }
// * Added properties by Silhwan Hyun
property StreamVersion: Byte read FStreamVersion;
property SerialNumber: integer read FSerialNo;
property ExtraTag: string read FExtraTag write FExtraTag;
end;
implementation
...
objeto : MICLASE |
|
#6
|
||||
|
||||
|
Bueno, en ese caso, para utilizarla tendrías que usar Project|Import Type Library...
pero, la verdad, no sé como crearla. ¿Alguien lo sabe? Es algo que me interesa saber a mí también. Gracias. |
|
#7
|
|||
|
|||
|
Venga, que seguro q no es dificil pero aun asi me estoy matando y no soy capaz, luego será una chorrada seguro
|
|
#8
|
|||
|
|||
|
Por dios, una ayudita!!!
|
|
#9
|
||||
|
||||
|
añades tu archivo pas tanto al programa como a la dll
en tu dll creas la siguiente funcion function devolverMiClase : longint begin result longint(TMiClases.create); end; en tu programa vuelves a hacer el casting function obtenerClase: TMiClase; begin result := TMiClase(devolverMiClase); end;
__________________
self.free; |
|
#10
|
|||
|
|||
|
Si añado el pas ami programa, no necesito hacer la dll
|
![]() |
|
|
Temas Similares
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| crear un evento en una clase? | chelox | OOP | 4 | 06-06-2007 20:14:20 |
| Crear eventos para una clase | DarkByte | OOP | 10 | 07-12-2005 20:02:28 |
| Crear clase. Basico de POO. | DarkByte | OOP | 17 | 24-08-2005 17:37:21 |
| Ayuda para crear una clase | estebanx | OOP | 0 | 10-03-2005 16:36:49 |
| Error al crear una instancia de clase | jplj | OOP | 2 | 15-02-2005 11:52:07 |
|