Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   C++ Builder (https://www.clubdelphi.com/foros/forumdisplay.php?f=13)
-   -   Snaked Library 1.0 (https://www.clubdelphi.com/foros/showthread.php?t=97540)

navbuoy 19-06-2025 04:24:05

Snaked Library 1.0
 
Código:

#ifndef SNAKEDLIBRARY_H
#define SNAKEDLIBRARY_H

#ifdef __cplusplus
extern "C" {
#endif

// Funciones exportadas
__declspec(dllimport) bool IsValidEmail(const char* email);
__declspec(dllimport) const char* GetCurrentDateTime();
__declspec(dllimport) int CalculateAge(const char* birth);
__declspec(dllimport) const char* ToUpperCase(const char* text);
__declspec(dllimport) const char* GenerateUUID();
__declspec(dllimport) int WordCount(const char* text);
__declspec(dllimport) void StartTimer();
__declspec(dllimport) double StopTimer();
__declspec(dllimport) void MicroDelay(long MicroSecs);
__declspec(dllimport) void ScreenShot(char*BmpName);
__declspec(dllimport) const char* PassHash(const char* passwd, int encoding);
__declspec(dllimport) const char* PT_Element(AnsiString Command);

#ifdef __cplusplus
}
#endif

#endif // SNAKEDLIBRARY_H

Estoy haciendo una libreria DLL con funciones propias

Pronto os pasare algo para que la probéis



os paso un capture de lo que voy haciendo:


Neftali [Germán.Estévez] 19-06-2025 09:29:13

^\||/^\||/^\||/^\||/

navbuoy 19-06-2025 16:53:56

He añadido algunas funciones mas:

Cita:

////////////////////////////////////////////////
// Using the function MicroDelay()
////////////////////////////////////////////////

void MilliDelay (long MilliSecs)
{
MicroDelay (MilliSecs * 1000);
}

////////////////////////////////////////////////


////////////////////////////////////////////////
// Using the function ScreenShot()
////////////////////////////////////////////////

AnsiString FILE_CAPTURE = "example.bmp";

ScreenShot(FILE_CAPTURE.c_str());

////////////////////////////////////////////////

////////////////////////////////////////////////
// Using the function SwitchGraphicMode()
////////////////////////////////////////////////

void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (SwitchGraphicMode(1280, 720, 32))
ShowMessage("Graphic Mode switched OK.");
else
ShowMessage("Error switching Graphic Mode, perhaps this mode not supported.");

ChangeDisplaySettings(NULL, 0); // Back Desktop mode by default
}

////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////
// Using the function PlayWAV()
////////////////////////////////////////////////

void __fastcall TForm1::Button1Click(TObject *Sender)
{
PlayWAV("C:\\Sonidos\\disparo.wav");
PlaySound(NULL, 0, 0); // STOP the current sound
}

////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////
// Using the function trim()
////////////////////////////////////////////////


void __fastcall TForm1::Button1Click(TObject *Sender)
{
char buffer[] = " texto con espacios ";
char* resultado = trim(buffer);
ShowMessage(AnsiString("Resultado: '") + resultado + "'");
}

Código:

#ifndef SNAKEDLIBRARY_H
#define SNAKEDLIBRARY_H

#ifdef __cplusplus
extern "C" {
#endif

// Funciones exportadas
// Elimina espacios al principio y final de una cadena
__declspec(dllimport) char* trim(char* str);

// Invierte una cadena
__declspec(dllimport) void reverse(char* str);

// Devuelve true (1) si la cadena es numérica
__declspec(dllimport) int isNumeric(const char* str);

// Convierte toda la cadena a minúsculas
__declspec(dllimport) void toLower(char* str);

// Reproduce Fichero de sonido WAV
__declspec(dllimport) void PlayWAV(const char* ruta);

// Cambia Modo Grafico del PC
__declspec(dllimport) bool SwitchGraphicMode(int width, int height, int bpp);

// Valida el E-Mail
__declspec(dllimport) bool IsValidEmail(const char* email);

// Obtiene Fecha/Hora Actual
__declspec(dllimport) const char* GetCurrentDateTime();

// Calcula una Edad con la fecha de nacimiento
__declspec(dllimport) int CalculateAge(const char* birth);

// Pone todo en MAYUSCULAS
__declspec(dllimport) const char* ToUpperCase(const char* text);

// Generar el UUID
__declspec(dllimport) const char* GenerateUUID();

// Cuenta el numero de palabras en el texto
__declspec(dllimport) int WordCount(const char* text);

// Timer de Tiempo "elapsed" inicia el contador
__declspec(dllimport) void StartTimer();

// Timer de Tiempo "elapsed" detiene el contador
__declspec(dllimport) double StopTimer();

// Funcion de DELAY de MicroSegundos
__declspec(dllimport) void MicroDelay(long MicroSecs);

// Capturador de PANTALLA del PC (archivo BMP)
__declspec(dllimport) void ScreenShot(char*BmpName);

// Encripta un Password con SHA
__declspec(dllimport) const char* PassHash(const char* passwd, int encoding);

// Obtiene informacion de la TABLA PERIODICA DE ELEMENTOS
__declspec(dllimport) const char* PT_Element(AnsiString Command);

#ifdef __cplusplus
}
#endif


navbuoy 20-06-2025 12:03:54

de momento ya llevo esto hecho:

Código:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Functions in Snaked Library 1.0
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void bubble_sort( int a[], int n );

DESCRIPTION: this function sort a array of int elements
IN: array of int numbers - number of elements
RETURN: nothing
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
char* trim(char* str);
DESCRIPTION: This function erase the spaces into the string
IN: char* string
RETURN: char* string trimmed (erase spaces)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
char* reverse(char* str);
DESCRIPTION: This function reverse the string
IN: char* string
RETURN: the same string but reversed
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int isNumeric(const char* str);
DESCRIPTION: This function say us if the string is numeric
IN: char* string
RETURN: int value (0 - No valid number  1 - Valid numeric string)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void toLower(char* str);
DESCRIPTION: This function change the characters to lowercase
IN: char* string
RETURN: nothing
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void PlayWAV(const char* ruta);
DESCRIPTION: This function play a WAV sound file using PlaySound Windows API func
IN: char* string with path and wav file
RETURN: nothing
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool SwitchGraphicMode(int width, int height, int bpp, int frequency);
DESCRIPTION: This function switch the Graphic Mode in the Desktop
IN: int width - int height - int bpp (bits per pixel) - int frequency
RETURN: int value (0 - Success -  other values - Error)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SaveOriginalGraphicMode()
DESCRIPTION: This function save the current Graphic Mode of the machine
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void RestoreOriginalGraphicMode()
DESCRIPTION: This function restore the original graphic mode previously saved
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool IsValidEmail(const char* email);
DESCRIPTION: This function validate a correct email address
IN: char* string with email
RETURN: int value (1 (True) - Success -  0 (False) - Error)

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const char* GetCurrentDateTime();
DESCRIPTION: This function returns the current Date/Time information
IN: Nothing
RETURN: const char* string with information of Date/Time
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CalculateAge(const char* birth);
DESCRIPTION: This function calculate the AGE from a birth Date
IN: const char* string with Date
RETURN: int value with Age
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const char* ToUpperCase(const char* text);
DESCRIPTION: This function change the string to UpperCase characters
IN: const char* text
RETURN: const char* with converted to UpperCase string
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const char* GenerateUUID();
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int WordCount(const char* text);
DESCRIPTION: This function count words in a given text
IN: const char* string (text)
RETURN: int value (Num of Words)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void StartTimer();
DESCRIPTION: This function start a internal elapsed time meter
IN: nothing
RETURN: nothing
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double StopTimer();
DESCRIPTION: Stop the elapsed time meter and return time elapsed in Milliseconds
IN: nothing
RETURN: double value (Milliseconds)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MicroDelay(long MicroSecs);
DESCRIPTION: This function make a Delay pause in MicroSecs
IN: long Microseconds
RETURN: Nothing
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void ScreenShot(char*BmpName)
DESCRIPTION: This function make a screen capture of the Desktop in BMP format
IN: char* string with bitmap filename (ended in .bmp)
RETURN: Nothing, just make the screenshot and write it in disk
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const char* PassHash(const char* passwd, int encoding);
DESCRIPTION: This function Encode a text string to a SHA encoded hashed password
IN: const char* passwd - int encoding (0) SHA224 - (1) SHA256 - (2) SHA384 - (3) SHA512

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const char* PT_Element(AnsiString Command);
DESCRIPTION: This function return information of the element of Periodic Table
IN: AnsiString Command (can be the numeric number of element, or name or element or formulation name)
RETURN: const char* with desired information

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


navbuoy 21-06-2025 16:20:04


navbuoy 21-06-2025 18:25:43


navbuoy 02-07-2025 21:34:42

he añadido la funcion que desarrollé para mi Fruits Player del tema de emisoras de Shoutcast para recuperar emisoras en una estructura asi de este tipo que ya incluye "SnakedLibrary.h"

Código:

struct TRadio
{
        AnsiString RadioName;
        AnsiString URL;
        int Listeners;
        int Bitrate;
        int ID;
};

struct TRadio Radio_Listing[3000];




la funcion es asi:

Código:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Retrieve_Radio_Stations(int indice, TRadio arr[], int max_stations)

DESCRIPTION: This function returns in a structure TRadio defined in SnakedLibrary.h
the amount of Radio Stations requested (max stations is 3000 cos the structure is defined as
Radio_Listing[3000] then only store a max of 0 to 2999 stations.

IN:
TRadio arr[] is the array defined as Radio_Listing[3000] for store the radios info and stream
int max_stations must be 3000 or less (same or less than the Radio_Listing array size)

int indice indicates the TOP STATIONS (0) or a genre defined as here:
(you only have pass to the function the number of genre


Neftali [Germán.Estévez] 03-07-2025 08:32:08

^\||/^\||/^\||/^\||/

Casimiro Noteví 03-07-2025 10:05:18

^\||/^\||/^\||/ ;)


La franja horaria es GMT +2. Ahora son las 06:57:04.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi