Page 1 of 1

Question about resources

Posted: Fri Mar 07, 2008 7:04 pm
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:

Posted: Fri Mar 07, 2008 11:59 pm
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)

Posted: Sat Mar 08, 2008 12:44 am
by Fluid Byte
UpdateResource() will mess up your EXE if father.exe doesn't already contain a string resource.

Posted: Sun Mar 09, 2008 8:37 am
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?

Posted: Sun Mar 09, 2008 12:39 pm
by srod
In the Purebasic IDE compiler options menu option, there is a tab through which you can add your .rc files etc.

Posted: Sun Mar 09, 2008 8:59 pm
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"?

Posted: Mon Mar 10, 2008 1:35 pm
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.

Posted: Wed Mar 12, 2008 6:27 pm
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?