Program Api

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
Dark Lord
Üye
Mesajlar: 3
Kayıt: 09 Oca 2009 10:49

Program Api

Mesaj gönderen Dark Lord »

Kod: Tümünü seç

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,mmsystem,shellapi, ExtCtrls ;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    Button10: TButton;
    Button11: TButton;
    Button12: TButton;
    Button13: TButton;
    Timer1: TTimer;
    Label2: TLabel;
    Timer2: TTimer;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
    procedure Button10Click(Sender: TObject);
    procedure Button11Click(Sender: TObject);
    procedure Button12Click(Sender: TObject);
    procedure Button13Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
   

  private
   procedure ListFiles(D,Name,SearchName : String);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}
 procedure TForm1.ListFiles(D,Name,SearchName : String);
var
    SR            : TSearchRec;
begin
  If D[Length(D)]<>'\' then
    D:=D+'\';
  If FindFirst(D+Name,faAnyFile,SR)=0then
    Repeat
      If (SR.Attr<>faDirectory) and (SR.Name[1]<>'.') then
        If AnsiUpperCase(SR.Name)=AnsiUpperCase(SearchName) then
          Label1.Caption:='Winamp installed on system in: ' + D+SR.Name;{If found then set label1.caption}
    Until (FindNext(SR)<>0);
  FindClose(SR);
  If FindFirst(D+'*.*',faDirectory,SR)=0 then
    begin
      Repeat
        If ((Sr.Attr and faDirectory)=faDirectory) and
            (SR.Name[1]<>'.') then
          ListFiles(D+SR.Name+'\',Name,SearchName);
      Until (FindNext(SR)<>0);
    end;
  FindClose(SR);
end;



procedure TForm1.Button1Click(Sender: TObject);
begin
ListFiles('c:\','*.*','winamp.exe');
end;

procedure TForm1.Button2Click(Sender: TObject);

var
hwndWinamp : THandle;
begin
    hwndWinamp := FindWindow('Winamp v1.x', nil);
    SendMessage(hwndWinamp, WM_COMMAND, 40045, 0);
end;

procedure TForm1.Button3Click(Sender: TObject);

var
hwndWinamp : THandle;
begin
hwndWinamp := FindWindow('Winamp v1.x', nil);
    SendMessage(hwndWinamp, WM_COMMAND, 40046, 0);
end;



procedure TForm1.Button4Click(Sender: TObject);

var
hwndWinamp : THandle;
begin
hwndWinamp := FindWindow('Winamp v1.x', nil);
    SendMessage(hwndWinamp, WM_COMMAND, 40047, 0);
end;

procedure TForm1.Button5Click(Sender: TObject);

var
hwndWinamp : THandle;
begin
hwndWinamp := FindWindow('Winamp v1.x', nil);
    SendMessage(hwndWinamp, WM_COMMAND, 40048, 0);
end;

procedure TForm1.Button6Click(Sender: TObject);

var
hwndWinamp : THandle;
begin
hwndWinamp := FindWindow('Winamp v1.x', nil);
    SendMessage(hwndWinamp, WM_COMMAND, 40044, 0);
end;

procedure TForm1.Button7Click(Sender: TObject);

var
hwndWinamp : THandle;
begin
hwndWinamp := FindWindow('Winamp v1.x', nil);
    SendMessage(hwndWinamp, WM_COMMAND, 40148, 0);
end;

procedure TForm1.Button8Click(Sender: TObject);

var
hwndWinamp : THandle;
begin
hwndWinamp := FindWindow('Winamp v1.x', nil);
    SendMessage(hwndWinamp, WM_COMMAND, 40144, 0);
end;

procedure TForm1.Button9Click(Sender: TObject);

var
hwndWinamp : THandle;
begin
hwndWinamp := FindWindow('Winamp v1.x', nil);
    SendMessage(hwndWinamp, WM_COMMAND, 40058, 0);
end;

procedure TForm1.Button10Click(Sender: TObject);

var
hwndWinamp : THandle;
begin
hwndWinamp := FindWindow('Winamp v1.x', nil);
    SendMessage(hwndWinamp, WM_COMMAND, 40059, 0);
end;

procedure TForm1.Button11Click(Sender: TObject);

var
hwndWinamp : THandle;
begin
hwndWinamp := FindWindow('Winamp v1.x', nil);
    SendMessage(hwndWinamp, WM_COMMAND, 40001, 0);
end;

procedure TForm1.Button12Click(Sender: TObject);
begin
ShellExecute(handle, 'open', pchar('c:\progra~1\winamp\winamp.exe'), nil, nil, SW_SHOWNORMAL);

end;

procedure TForm1.Button13Click(Sender: TObject);
begin
 Form2.DragKind:=dkDock;
Form2.DragMode:=dmAutomatic;
Form2.Show;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Label2.Caption:='WİNAMP KONTROL PANELİ';
Label2.Color:= clBlack; // rengini belirler
Label2.Font.Color:=clWindow;// yazi tipini belirler
Label2.Font.Style:=Label1.Font.Style+[fsBold,fsItalic]

end;

procedure TForm1.Timer1Timer(Sender: TObject);

var
c:TColor;
begin
c:=Label1.Color;
Label1.Color:=Label1.Font.Color;
Label1.Font.Color:=c;
End;



procedure TForm1.Timer2Timer(Sender: TObject);
begin
Form1.Caption:='Coded By   .: ISIMSIZ :.   [ '+TimeToStr(time) +' ]';
end;

end.
Arkadaşlar abilerim kardeşlerim bu Winamp Api kontrol programı ben bunu winamp tan başka bir program için tasarlıyacağım ama size sormam gereken birşey var ve cevaplarınız benim için çok büyük değer taşıyor

Kod: Tümünü seç

procedure TForm1.Button2Click(Sender: TObject);

var
hwndWinamp : THandle;
begin
    hwndWinamp := FindWindow('Winamp v1.x', nil);
    SendMessage(hwndWinamp, WM_COMMAND, 40045, 0);
end;
Yukarıdaki kod winamp api programı arasında forum üzerinde Başlat butonunun görevi bu kodu bana açıklarmısınız benim için asıl önemli olan burada 40045 isimli sayı bir ascii kod mu yani klavye girdisindeki C nin kodumu yoksa winamp programında play tuşunun ID ismi mi bu konuda çok kafa yordum lütfen cevaplarınızı esirgemeyin
ibrahimcoban
Üye
Mesajlar: 163
Kayıt: 11 Eki 2005 10:44
İletişim:

Re: Program Api

Mesaj gönderen ibrahimcoban »

Play tuşunun ID olabilir yada özel bir komut.
Delphi karşılığı şöyle olabilir.

Kod: Tümünü seç


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    procedure WndProc(var Message: TMessage); override;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WndProc(var Message: TMessage);
begin
  inherited;
  if Message.WParam = 40045 then
  begin
    if Message.Msg = WM_COMMAND then
    begin
      ShowMessage('Çal');
    end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  SendMessage(Handle, WM_COMMAND, 40045, 0);
end;

end.


http://ibrahimcoban.com/
Lazarus, Kol-Ce,Delphi ve C#
Jire
Üye
Mesajlar: 167
Kayıt: 07 Eki 2007 01:20

Re: Program Api

Mesaj gönderen Jire »

Biri bana API mi dedi?
Buyur Api, c++da kodlanmış.

Kod: Tümünü seç

/* Created by Ghost5316 (MBald)
 * You may change this file in any way you like,
 * please include my name when redistributed
 */

#include <windows.h>
#include <iostream>
#include <string>
using namespace std;

const long cPrevTrack = 40044;           // Previous track button
const long cNextTrack = 40048;           // Next track button
const long cStartPlay = 40045;           // Play button
const long cPausePlay = 40046;           // Pause/Unpause button
const long cStopPlay = 40047;            // Stop button
const long cFadeAndStop = 40147;         // Fadeout and stop
const long cStopAfterTrack = 40157;      // Stop after current track
const long cForward5Secs = 40148;        // Fast-forward 5 seconds
const long cRewind5Secs = 40144;         // Fast-rewind 5 seconds
const long cStartOfPlaylist = 40154;     // Start of playlist
const long cEndOfPlaylist = 40158;       // Go to end of playlist
const long cRaiseVol = 40058;            // Raise volume by 1%
const long cLowerVol = 40059;            // Lower volume by 1%
const long cExecuteVisualPlugin = 40192; // Execute current visualization plug-in
const long cShowMainWindow = 40258;      // Toggle main window visible
const long cConfigureVisual = 40221;     // Configure current visualization plug-in
const long cReloadSkin = 40291;          // Reload the current skin
const long cCloseWinamp = 40001;         // Close Winamp
const long cPrev10Tracks = 40197;        // Moves back 10 tracks in playlist
const long cAddTrackAsBook = 40321;      // Adds current track as a bookmark
const long cPlayAudioCD = 40323;         // Play audio CD
const long cLoadPresetFromEQ = 40253;    // Load a preset from EQ
const long cSavePresetToEQ = 40254;      // Save a preset to EQF
const long cLoadDefaultPreset = 40174;   // Load default preset
const long cToggleTimeElapsed = 40037;   // Set time display mode to elapsed
const long cToggleTimeRemaining = 40038; // Set time display mode to remaining
const long cTogglePrefs = 40012;         // Toggle preferences screen
const long cToggleAbout = 40041;         // Toggle about box
const long cToggleTitleScroll = 40189;   // Toggle title Autoscrolling
const long cToggleOnTop = 40019;         // Toggle always on top
const long cToggleMainShade = 40064;     // Toggle Windowshade
const long cTogglePLShade = 40266;       // Toggle Playlist Windowshade
const long cToggleDoubleSize = 40165;    // Toggle doublesize mode
const long cToggleEQ = 40036;            // Toggle EQ
const long cTogglePlaylist = 40040;      // Toggle playlist editor
const long cToggleMiniBrows = 40298;     // Toggle minibrowser
const long cToggleEasymove = 40186;      // Toggle easymove
const long cToggleRepeat = 40022;        // Toggle repeat
const long cToggleShuffle = 40023;       // Toggle shuffle
const long cOpenFile = 40029;            // Open file dialog
const long cOpenURL = 40155;             // Open URL dialog
const long cOpenFileInfo = 40188;        // Open file info box
const long cOpenPlugOpts = 40190;        // Open visualization options
const long cOpenVisualPlugOpts = 40191;  // Open visualization plug-in options
const long cOpenJumptoTime = 40193;      // Open jump to time dialog
const long cOpenJumptoFile = 40194;      // Open jump to file dialog
const long cOpenSkinSel = 40219;         // Open skin selector
const long cOpenEditBookmarks = 40320;   // Show the edit bookmarks
const long cOpenLoadPreset = 40172;      // Opens load presets dialog
const long cOpenAutoLoadPresets = 40173; // Opens auto-load presets dialog
const long cOpenSavePreset = 40175;      // Opens save preset dialog
const long cOpenAutoLoadPreset = 40176;  // Opens auto-load save preset
const long cOpenDeletePreset = 40178;    // Opens delete preset dialog
const long cOpenDeleteAutoLoad = 40180;  // Opens delete an auto load preset dialog
HWND hwndWinamp;

void sendMsg(long ID) {
	long x = SendMessage(hwndWinamp, WM_COMMAND, ID, NULL);
}

void showPlaybackStatus() {
	int ret=SendMessage(hwndWinamp,WM_USER, 0, 104);
	if(ret == 1) {
		cout << "Playing";
	} else if(ret == 3) {
		cout << "Paused";
	} else {
		cout << "Stopped";
	}
}

void showPlayingTime() {
	int ret=SendMessage(hwndWinamp,WM_USER, 0, 105);
	ret = ret / 1000;
	int min = ret / 60;
	int sec = ret - min*60;
	if(sec < 10)
		cout << min << ":" << "0" << sec;
	else
		cout << min << ":" << sec;
}

void showPlayingLength() {
	int ret=SendMessage(hwndWinamp,WM_USER, 1, 105);
	int min = ret/60;
	int sec = ret - min*60;
	if(sec < 10)
		cout << min << ":" << "0" << sec;
	else
		cout << min << ":" << sec;
}

void showPlaylistSize() {
	int ret=SendMessage(hwndWinamp,WM_USER, 1, 124);
	cout << ret;
}

void showBitRate() {
	int ret=SendMessage(hwndWinamp,WM_USER, 1, 126);
	cout << ret;
}

void showSampleRate() {
	int ret=SendMessage(hwndWinamp,WM_USER, 0, 126);
	cout << ret*1000;
}

void showRepeatToggle() {
	int ret=SendMessage(hwndWinamp,WM_USER, 0, 251);
	if(ret == 1)
		cout << "On";
	else
		cout << "Off";
}

void showShuffleToggle() {
	int ret=SendMessage(hwndWinamp,WM_USER, 0, 250);
	if(ret == 1)
		cout << "On";
	else
		cout << "Off";
}

void showTitle() {
	char this_title[2048],*p;
	GetWindowText(hwndWinamp,this_title,sizeof(this_title));
	p = this_title+strlen(this_title)-8;
	while (p >= this_title)
	{
		if (!strnicmp(p,"- Winamp",8)) break;
		p--;
	}
	if (p >= this_title) p--;
	while (p >= this_title && *p == ' ') p--;
	*++p=0;
	cout << this_title;
}	

void main(long argc, char *argv[]) {
    hwndWinamp = FindWindow("Winamp v1.x", NULL);
	string x = "";
	if(argc > 1) { x = argv[1]; }


	if(x == "play") { sendMsg(cStartPlay); }
	else if(x == "stop")             { sendMsg(cStopPlay); }
	else if(x == "pause")            { sendMsg(cPausePlay); }
	else if(x == "next")             { sendMsg(cNextTrack);	}
	else if(x == "prev")             { sendMsg(cPrevTrack); }
	else if(x == "vol_up")           { sendMsg(cRaiseVol); }
	else if(x == "vol_down")         { sendMsg(cLowerVol); }
	else if(x == "stop_with_fade")	 { sendMsg(cFadeAndStop); }
	else if(x == "toggle_playlist")	 { sendMsg(cTogglePlaylist); }
	else if(x == "toggle_eq")        { sendMsg(cToggleEQ); }
	else if(x == "toggle_shuffle")   { sendMsg(cToggleShuffle); }
	else if(x == "toggle_repeat")    { sendMsg(cToggleRepeat); }
	else if(x == "forward_5_seconds"){ sendMsg(cForward5Secs); }
	else if(x == "rewind_5_seconds") { sendMsg(cRewind5Secs); }
	else if(x == "open_file")        { sendMsg(cOpenFile); }
	else if(x == "show_winamp")      { sendMsg(cShowMainWindow); }
	else if(x == "open_url")         { sendMsg(cOpenURL); }
	else if(x == "open_file")        { sendMsg(cOpenFile); }
	else if(x == "play_audiocd")     { sendMsg(cPlayAudioCD); }	
	else if(x == "visualization")    { sendMsg(cExecuteVisualPlugin); }
	else if(x == "stop_when_done")   { sendMsg(cStopAfterTrack); }
	else if(x == "get_title")		 { showTitle(); }
	else if(x == "get_status")		 { showPlaybackStatus(); }
	else if(x == "get_playlength")	 { showPlayingLength(); }
	else if(x == "get_playtime")	 { showPlayingTime(); }
	else if(x == "get_playlistsize") { showPlaylistSize(); }
	else if(x == "get_bitrate")      { showBitRate(); }
	else if(x == "get_samplerate")   { showSampleRate(); }
	else if(x == "get_shuffletoggle"){ showShuffleToggle(); }
	else if(x == "get_repeattoggle"){ showRepeatToggle(); }
	else {
		cout << "Arguments : " << endl;
		cout << "	play" << endl;
		cout << "	stop" << endl;
		cout << "	pause" << endl;
		cout << "	next" << endl;
		cout << "	prev" << endl;
		cout << "	vol_up" << endl;
		cout << "	vol_down" << endl;
		cout << "	stop_with_fade" << endl;
		cout << "	toggle_playlist" << endl;
		cout << "	toggle_eq" << endl;
		cout << "	toggle_shuffle" << endl;
		cout << "	toggle_repeat" << endl;
		cout << "	forward_5_seconds" << endl;
		cout << "	rewind_5_seconds" << endl;
		cout << "	open_file" << endl;
		cout << "	show_winamp" << endl;
		cout << "	open_url" << endl;
		cout << "	open_file" << endl;
		cout << "	play_audiocd" << endl;
		cout << "	visualization" << endl;
		cout << "	stop_when_done" << endl;
		cout << "	get_title" << endl;
		cout << "	get_status" << endl;
		cout << "	get_playlength" << endl;
		cout << "	get_playtime" << endl;
		cout << "	get_playlistsize" << endl;
		cout << "	get_bitrate" << endl;
		cout << "	get_samplerate" << endl;
		cout << "	get_shuffletoggle" << endl;
		cout << "	get_repeattoggle" << endl << endl;
		cout << "::   post to the forums if you want any more functionality    ::" << endl;
		cout << "::         (make surey you explain what you want :-p)         ::" << endl;
		cout << ":: Note: a select few functions only work in winamp ver 2.5+  ::" << endl;
	}
}
Ek Bilgi: Nasıl birşey bu dersen kodda üst tarafta verilen 40k'li numaralar komutların numaraları.
Tek yapman gereken orada yanında ne işe yaradığı okuyup istediğini almak.
Ya da kodu derlersin ve komut sistemi gibi kullanırsın ki orada yazan play stop gibi komutları yazdığında o handle için sendmessage ile o numarayı gönderecektir.

Bu tamamiyle senin istediğin birşey, delphi'ye çevirebileceğini düşünerek sana bırakıyorum.
Dark Lord
Üye
Mesajlar: 3
Kayıt: 09 Oca 2009 10:49

Re: Program Api

Mesaj gönderen Dark Lord »

işte, tam olarak şöylemeye çalıştığım nokta ... 40045 gibi numaraları ben nereden bulurum mesela winamp için değil media player için veya WinDVD gibi başka bir program için ben bu numaraları nasıl bulabilirim
Dark Lord
Üye
Mesajlar: 3
Kayıt: 09 Oca 2009 10:49

Re: Program Api

Mesaj gönderen Dark Lord »

yokmu arkadaşlar API leri bulabilmem için bir program filan ? bana API değerleri nasıl bulunur bu lazım
ibrahimcoban
Üye
Mesajlar: 163
Kayıt: 11 Eki 2005 10:44
İletişim:

Re: Program Api

Mesaj gönderen ibrahimcoban »

Api değerlerini yukardaki gibi bulamazsın fakat pencerelerin (windows işletim sisteminde her şey pençeredir) handle numaralarını
alabilirsin. Micrososft Spy++ ile bunları alıp tuş falan gönderebilirsin.
http://ibrahimcoban.com/
Lazarus, Kol-Ce,Delphi ve C#
Cevapla