mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2006
Posts: 5
V
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
V
Joined: Oct 2006
Posts: 5
ok here is part of c++ code:
Quote:

//execInMirc stuff
#define WM_MCOMMAND (WM_USER + 200)
HWND *mHwnd;
LPSTR mData = NULL;
HANDLE hMap = NULL;
//execInMirc stuff end


void execInMircInit(HWND *mh)
{
mHwnd = mh;
hMap = CreateFileMapping(INVALID_HANDLE_VALUE,0,PAGE_READWRITE,0,1024,"mIRC");
mData = (LPSTR)MapViewOfFile(hMap,FILE_MAP_ALL_ACCESS,0,0,0);
}

void execInMirc(const std::string &s)
{
#ifdef COMP_EXE
std::cout << "EIM: " << s << std::endl;
return;
#endif
wsprintf(mData, s.c_str());
SendMessage(*mHwnd, WM_MCOMMAND, 0, 0);
}

void execInMirc(const char *s)
{
std::string mmsg = s;
execInMirc(mmsg);
}


void execInMircShutdown()
{
UnmapViewOfFile(mData);
CloseHandle(hMap);
}

now if I send any string to execInMirc that contains % symbol, it causes mirc to crash.
for instance: execInMirc("/echo -s Hello % World!"); will cuase crash.

So is there any other way to send command to the mirc that contains % sign without using standart returns from dll with data parameter?

Last edited by Vycka_Xxx; 24/02/10 04:13 PM.
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
mirc has a SendMessage() function that you can use to communicate applications with it.

Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
Quote:
wsprintf(mData, s.c_str());

strcpy(mData, s.c_str());


Saturn, QuakeNet staff
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
As Sat pointed out, your issue isn't with "%", it's with your use of wsprintf() which both interpolates a format (in which "%" has special meaning) as well as the fact that you're sending wide-chars to mIRC.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Oct 2006
Posts: 5
V
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
V
Joined: Oct 2006
Posts: 5
OH Crap, how did I managed to forget that stuff about %d %f and so on.
Big THANKS guys.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
On behalf of the helpers that were able to help: "Your Welcome"

Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
Originally Posted By: RusselB
On behalf of the helpers that were able to help: "Your Welcome"

I'm sure you meant well, but please do not do this.


Saturn, QuakeNet staff

Link Copied to Clipboard