Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Embedding .XM and player Delphi

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Wed Aug 29, 2007 8:07 pm    Post subject: Embedding .XM and player Delphi Reply with quote

Well today, i wanted to embed a .XM into my Delphi app, and play it, i googled, and searched, ect. i could never get it to work tho in the end. This is as close as i got:

Quote:

Create a Resource file.
First fire up Notepad, and type in:

Code:

mus_XM XM "MS.XM"


Then save it as Resources.rc.
I ran SDK and compiled it using:

Code:

Rc /r Resources.rc


That shouldve compiled the Rc file into a Resource File.

Now in my App, i had to make sure it was implemented in :

Code:

($Resources)


Now that the resource for the Xm file is done i had to now find a way to put the Xm into memory and call it from the App.

Code:

var
Music_XM: pointer;


 function GetResourceAsPointer(ResName: pchar; ResType: pchar;

                                out Size: longword): pointer;
  var
    InfoBlock: HRSRC;
    GlobalMemoryBlock: HGLOBAL;
  begin
    InfoBlock := FindResource(hInstance, resname, restype);
    if InfoBlock = 0 then
      raise Exception.Create(SysErrorMessage(GetLastError));
  size := SizeofResource(hInstance, InfoBlock);
    if size = 0 then
     raise Exception.Create(SysErrorMessage(GetLastError));
    GlobalMemoryBlock := LoadResource(hInstance, InfoBlock);
    if GlobalMemoryBlock = 0 the
      raise Exception.Create(SysErrorMessage(GetLastError));
    Result := LockResource(GlobalMemoryBlock);
    if Result = nil then
      raise Exception.Create(SysErrorMessage(GetLastError));
  end;



  function GetResourceAsString(ResName: pchar; ResType: pchar): string;
  var
    ResData: PChar;
 ResSize: Longword;
  begin
    ResData := GetResourceAsPointer(resname, restype, ResSize);
    SetString(Result, ResData, ResSize);
  end;


procedure TForm1.FormCreate(Sender: TObject);

  var

    size: longword;

  begin


    Music_MX := GetResourceAsPointer('Music_XM', 'XM', size);
end;



Now to call it to play:

Code:

sndPlaySound(sample_wav, SND_MEMORY or SND_NODEFAULT or SND_ASYNC);





After all this, i still wasnt able to successfully embed the XM file in and play it. Can anyone take a look and give a review, that could help?
[/quote]
Back to top
View user's profile Send private message AIM Address MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites