can I use fopen,and fwrite with ShellExecute?

to take file in buffer,drop it in directory and run it with ShellExecute

I did this way but I just get cmd window and file is corupted

do I have to use some API to take file in buffer?

Recommended Answers

Well yes.
You can pretty much fwrite a file, then ShellExecute it to open it from the disk using it's current associated editor.

FILE *file = fopen("D:\\myText.txt","w");
fputs(file, "HellO");
fclose(file);
ShellExecute(NULL,"open","D:\\myText.txt","","", SW_NORMAL);
Jump to Post
int fBytes = fseek(file, 0 , SEEK_END );
char *buffer = new char[fBytes];
fread(file, buffer, fBytes);
Jump to Post

All 6 Replies

Well yes.
You can pretty much fwrite a file, then ShellExecute it to open it from the disk using it's current associated editor.

FILE *file = fopen("D:\\myText.txt","w");
fputs(file, "HellO");
fclose(file);
ShellExecute(NULL,"open","D:\\myText.txt","","", SW_NORMAL);

how to read all binary data from "D:\\myText.txt" or "D:\\myPic.jpg" into buffer?

which function?

if I use pointer FILE* file and size of it,it's not shellcode of myPic.jpg

int fBytes = fseek(file, 0 , SEEK_END );
char *buffer = new char[fBytes];
fread(file, buffer, fBytes);
int fBytes = fseek(file, 9 , SEEK_SET );
char *buffer = new char[fBytes];
fread(file, buffer, fBytes);

ok,thank you!

I just need info how to switch from debug build mode to release mode build in VC++6

I've found it!

thank you very much,you solved the thread!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.