Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SendMessage to another application having trouble.

Posted on 2004-10-30
15
Medium Priority
?
168 Views
Last Modified: 2010-04-05
SendMessage(BBHwnd, BB_SETSTYLE, 0, LPARAM(FileN));

BBhwnd is set before this BB_SETSTYLE is a constant defined with the correct ID and FileN is a string containing a filename.

Im trying to send this to BlackBox and alt shell for windows made in c++ but it returns the error 'unable to open file "".' as if it is getting nothing.

Ive tryed alot of diff ways to send FileN and they either crash blackbox or get this error(see above).
0
Comment
Question by:Chesso
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 2
  • +1
15 Comments
 
LVL 7

Expert Comment

by:LRHGuy
ID: 12455304
This is a guess, but maybe it should be a pointer to the string:

SendMessage(BBHwnd, BB_SETSTYLE, 0, LPARAM(@FileN));
0
 
LVL 7

Expert Comment

by:LRHGuy
ID: 12455312
Or maybe a pchar?

SendMessage(BBHwnd, BB_SETSTYLE, 0, LPARAM(pChar(FileN)));
0
 

Author Comment

by:Chesso
ID: 12455845
Ive already tryed both using pointer gets the same error and PChar crashes blackbox.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 12

Assisted Solution

by:esoftbg
esoftbg earned 140 total points
ID: 12456149
May be:
  SendMessage(BBHwnd, BB_SETSTYLE, Longint(Handle), Longint(@FileN));
0
 

Author Comment

by:Chesso
ID: 12456401
hmm nop still says unable to open file " " this is very strange ive seen plugins dev for blackbox that manage to succeed with this message but they are made in c++.
0
 
LVL 7

Expert Comment

by:LRHGuy
ID: 12456468
Maybe you need to make sure the string is an ASCIIZ string on the heap. I tried this in a delphi pgm, and it works. The c++ program might still not be getting the data. (Also, have you verifyed then FileN is not empty?)

  P:pchar;

  getmem(P,length(FileN)+1);
  SendMessage(BBHwnd,BB_SetStyle,0,LParam(StrPCopy(P,FileN)));
  freemem(P,length(FileN)+1);
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12456505
I have code for sending text between 2 Delphi applications, but both Sender-app and Receiver-app contain specific procedures i.e. it is not a one side process (Sender sends a string, Receiver decides what to do with the string) ....
0
 

Author Comment

by:Chesso
ID: 12456637
LRHGuy delphi says incompatible types: 'String' and 'PAnsiChar'

FileN does contain a filename and it is a string.
0
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 160 total points
ID: 12456803
Problem is that you're trying to send an address from process 1 to process 2. The address is located in process 1. In process 2 there's just nothing at that address, thus it just fails. It's a bit similar to the usage of the WM_COPYDATA message. <quote> The data being passed must not contain pointers or other references to objects not accessible to the application receiving the data. While this message is being sent, the referenced data must not be changed by another thread of the sending process. The receiving application should consider the data read-only. The lParam parameter is valid only during the processing of the message. The receiving application should not free the memory referenced by lParam. If the receiving application must access the data after SendMessage returns, it must copy the data into a local buffer. </quote>
Sending data between processes can be a real pain if done through messages. It could well be that you have to use a global variable of type PChar somewhere that will contain the text that you will send over, just so the other process might still be able to process it. But even then there's a lot that could go wrong.
0
 
LVL 7

Expert Comment

by:LRHGuy
ID: 12456831
Sorry, should be:

P:pAnsiChar;
0
 

Author Comment

by:Chesso
ID: 12456887
I think it's complaining about FileN being a string.

PChar? isnt a char a single character how would that work im only used to string/integer and such as i use them regularly.

I don't know if anyone would be interested but Blackbox is open source ive viewed the particular section where it handles BB_SETSTYLE but i dont know much about c++ so alot of it was garble to me lol.
0
 
LVL 7

Assisted Solution

by:LRHGuy
LRHGuy earned 200 total points
ID: 12457009
The sample compiled fine here in my D7, and it worked as I said, D7 to D7.

Here's my test routine...

procedure TForm2.Button2Click(Sender: TObject);
var
  P:pAnsiChar;
  FileN:String;
begin
  FileN:='test';

  getmem(P,length(FileN)+1);
  SendMessage(Handle,BB_SetStyle,0,LParam(StrPCopy(P,FileN)));
  freemem(P,length(FileN)+1);

end;
0
 

Author Comment

by:Chesso
ID: 12459064
Ok i did it right before im sure but it complained so i copied what you just wrote or the parts atleast that apply and it did compile but came up with an error why i tried to use it.

The instruction at "0x77f8ffde" refereced memory at "0x00c5a4dc". The memeory could not be "read".
0
 

Author Comment

by:Chesso
ID: 12460001
Iv'e just viewed the source for a plugin that switches styles called BBStyle a c++ dll plugin and it works using for example...

SendMessage(BBHwnd, BB_SETSTYLE, 0, (LPARAM)styletoset)

Not sure exactly what type styletoset is though but it works as a loaded plugin.
0
 

Author Comment

by:Chesso
ID: 12461230
im not going to bother nemore it just wont work ive managed to almost have the same thing in c++ and it is atleast saing undable to find file "@%#%^$" some characters not what i sent but still almost there. Ill split da points up
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question