Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OpenDialog : Get the adress (WORD *) of a file

Status
Not open for further replies.

slapierre

Programmer
Feb 3, 2004
16
CA
Greetings,

I need to get the adress of a wave file, I used and OpenFile dialog to get the path, now I want to transform the AnsiString into an address (in other words, I want to change a path into an adress). Here's a piece of code that I wrote for an on-click event, I have no clue on how to get the address of the char * string :

void __fastcall TFORM_SonoDrive::CMD_OpenAudioStreamClick(
TObject *Sender)
{
WORD * Addr;
Char * CharPath;
AnsiString StrPath;

if (ODG_OpenAudioStream->Execute())
{
StrPath = ODG_OpenAudioStream->FileName;
CharPath = StrPath.c_str();
Label1->Caption = StrPath;
Label2->Caption = CharPath; // the path is ok
// get an address out of a path :
// *Addr = *((WORD *)CharPath); <- crashes at run-time
}
}
I tried a typecast but it crashed.

Simon Lapierre
slapierre@sonomax.com
 
I think what you want is the address pointed to by CharPath.
Sorry if I'm not understanding you correctly.

Try:
Code:
    Addr = (WORD *) CharPath;

Good Luck.
 
I don't understand what you mean by address. You want the memory address of the character pointer? You say *Addr = something before you ever assign Addr to a location. See, when you created Addr:

WORD *Addr;

It has no data, because it's not pointing to a WORD yet. So if you dereference it (*Addr=1 for instance) it will crash.

The main thing is I don't understand what address you need. The CharPath pointer should be all you need to work with string data... Maybe you can provide further details, like what is the WORD* Addr being used for. If you want the memory location of the character pointer, you would want to say DWORD Addr = &CharPath.

Chris
 
Supernat03:

The WORD* Addr will contain the audio data stream buffer (wav file) start address, I used an OpenDialog to select which file to send, the OpenDialog->Filename returned an AnsiString, now I want to get the address of the selected file. I want to get the address of a file from its path so i can send it as a parameter to a function in a DLL.

Simon Lapierre
slapierre@sonomax.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top