Question about resources

Just starting out? Need help? Post your questions and find answers here.
PBUser
User
User
Posts: 20
Joined: Mon Aug 20, 2007 6:03 pm
Location: Germany

Question about resources

Post by PBUser »

Hi,

i'm sorry - i haven't found anything that helped me to solve this problem. I want to update a string by using resources.

Here's my source for the father:

Code: Select all

h = BeginUpdateResource_("client.exe", 0)
*buffer = AllocateMemory(255)
size=255
 r = UpdateResource_(h, 1, "TEST", 0, *buffer, size)
 r = EndUpdateResource_(h, 0)
Here's the child:

Code: Select all

text$ = Space(255)
TextWnd = LoadString_(hinstance,1,@text$,10)
If TextWnd <> 0
  MessageRequester("Info", PeekS(TextWnd))
  MessageRequester("Info", Str(TextWnd))
Else
  MessageRequester("error","no resource")
EndIf
If i run the client.exe the first time, i get "No Resource", but when i run the father.exe and then the client.exe, I get a message from windows that my client.exe is not a vaild program.

I hope you can help me... :lol:
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

I am not an expert on PArent/child windows but I believe you have to use the Scintilla Gadget for interwindow communication. 8)
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

UpdateResource() will mess up your EXE if father.exe doesn't already contain a string resource.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
PBUser
User
User
Posts: 20
Joined: Mon Aug 20, 2007 6:03 pm
Location: Germany

Post by PBUser »

I created a resource file with Resource Builder:

Code: Select all

/*********************************************
File: C:\DOKUMENTE UND EINSTELLUNGEN\ADMIN\DESKTOP\TST\RESOURCE.RC
Generated by Resource Builder (2.6.4.1).
*********************************************/
/*
OutputExt=res
*/
STRINGTABLE
MOVEABLE PURE LOADONCALL DISCARDABLE
LANGUAGE LANG_NEUTRAL, 0
BEGIN
0,  "Hallo"
END
How can I include the file in my PB-Project?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

In the Purebasic IDE compiler options menu option, there is a tab through which you can add your .rc files etc.
I may look like a mule, but I'm not a complete ass.
PBUser
User
User
Posts: 20
Joined: Mon Aug 20, 2007 6:03 pm
Location: Germany

Post by PBUser »

Thanks for reply. I've created a resource-file with ResEd.
That's the content:

Code: Select all

STRINGTABLE DISCARDABLE
BEGIN
  1 "Halloooooo"
  2 "What do you want"
END
That's my code for reading the resource:

Code: Select all

*text = AllocateMemory(255)
hinstance = OpenLibrary(0,"user32.dll")
TextWnd = LoadString_(hinstance,1,*text,255)
If TextWnd <> 0
  MessageRequester("Info", PeekS(TextWnd))
  MessageRequester("Info", Str(TextWnd))
Else
  MessageRequester("error","no resource")
EndIf
Why do I get the MessageRequester "no resource"?
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

PBUser wrote:Why do I get the MessageRequester "no resource"?
1.) The file user32.dll doesn't contain a string at ID#1. Try 2, 13, 14 or 700 instead. To find out wich ID's actually contain a string get an editor like XN Resource Editor.

2.) You try to show the result of 'TextWnd' instead of the varibale '*text' wich holds the pointer to the textbuffer.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
PBUser
User
User
Posts: 20
Joined: Mon Aug 20, 2007 6:03 pm
Location: Germany

Post by PBUser »

Hmm... Still doesn't work....

Maybe it is because i haven't entered a name for the resources? Here's a screenshot of the Stringtable I created with ResEd:

Image

If I enter the same name, I get an error by PureBasic (Duplicate String ID) What shall I do now? Is there any tutorial how to do that?
Post Reply