mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 3 1 2 3
#139733 18/01/06 01:56 AM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
if i save stuff to arrays in the dll, is it possible to keep them in the dll even if i close mirc, or will i lose them?

like with hash tables we can write hash entries to text file on EXIT, and load them again in start

#139734 18/01/06 05:35 AM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
The dll will be unloaded when mIRC closes so you will lose them.

#139735 18/01/06 07:17 AM
Joined: Dec 2002
Posts: 580
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
look at fopen(), fread(), fwrite(), and fclose() for basic file I/O... For an array you would need to write the number of bytes in the array to a file...

[code]
#define SIZE 50
void Test(void) {
char array[SIZE] = "This is a character array";
FILE *fp
// Modes r=read, w=write, a=append, r+ = read/write existing...
fp = fopen("filename", "r+");
fwrite(array, SIZE, 1, fp);
array[0] = 0;
fread(array, SIZE, 1, fp);
fclose(fp);
}


NaquadaBomb
www.mirc-dll.com
#139736 18/01/06 07:25 AM
Joined: Dec 2002
Posts: 580
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
If you want to save dynamically allocated memory between Unload and "Reload" of a DLL without quiting mIRC... Consider saving pointers, to dynamically allocated memory, in a window property, GetProp(hwnd, "PropName") and SetProp(hwnd, "PropName", propValuePtr), there is also a RemoveProp(hwnd, "PropName")....


NaquadaBomb
www.mirc-dll.com
#139737 18/01/06 02:40 PM
Joined: Jan 2003
Posts: 249
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
fwrite( array, sizeof( item ), number of items, fp );

yes it's 1 for a char, but if you have an array of something else, you won't get what you expect.

fwrite( array, sizeof( char ), strlen( text ), fp );

#139738 18/01/06 06:39 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
thanks a bunch guys, has anyone got any simple tuts or anything on arrays in c++, because what i want to do is create an array so i can store data for different things, e.g..

(#Channel) (Visted)
#hello 7
#mirc 0
#net 9

#139739 18/01/06 06:41 PM
Joined: Jan 2003
Posts: 249
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
why do you use a DLL to store stuff when mIRC has already the tools for that in INI files, hash tables or plain text files ?

And arrays in C++ are different from other languages like PHP arrays where you can have "keys" to identify an item. There is no such thing natively in C++. But you can use STL containers to achieve a similar result but this is somewhat an advanced topic in C++.

Last edited by ClickHeRe; 18/01/06 06:44 PM.
#139740 18/01/06 07:20 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
ah ok thanks, Im just asking for testing purposes etc

#139741 19/01/06 09:01 AM
Joined: Jan 2003
Posts: 1,063
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2003
Posts: 1,063
because arrays in c have a predefined size it's hard to store dynamic data in it.

I would suggest using c++ and then either a linked list of channel objects, or a vector because both are variable of size


If it ain't broken, don't fix it!
#139742 19/01/06 03:07 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
so something like this

/dll Test.dll TestStore #channel hello

i could make that using linked lists then? to store the data 'hello' into a table/list of somekind called #channel ?

and could i do this to retrieve the data for that channel

//echo -a $dll(Test.dll, getData, #channel)

ill have a look at linked lists then!

#139743 19/01/06 03:09 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Linked lists are exactly like hashtables. You specify the type of key you'll be storing and the type of data you'll be storing when you initialise the list.

#139744 19/01/06 03:39 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
thanks, i'll have a crack at it and post back later

but using a link list, if i wanted to say foe e.g, grab the data inside the key called #mirc, would i have to scan through all the nodes in the list?

Last edited by pouncer; 19/01/06 03:40 PM.
#139745 19/01/06 04:10 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
No. That's done by the system.

#139746 19/01/06 05:45 PM
Joined: Jan 2003
Posts: 249
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
use an STL hash map for a key/value relationship like mIRC's hash tables (which I think is implemented using a wrapper around a hash map)

#139747 19/01/06 06:28 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Er that's actually what I mean heh. I don't know why I thought of linked lists when I meant maps.

map<keytype,datatype> blah;

#139748 21/01/06 01:37 AM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
ah, maps!

so are hash maps and maps the same thing?

and any of you guys ever used them before for anything?

#139749 21/01/06 03:34 AM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
ok well ive had a crack at it...

Code:
//declarations at the top
#include &lt;map&gt;
#include &lt;string&gt;
using namespace std;

typedef map&lt;string, string&gt; TestMap;

//export function..
extern "C" int WINAPI Test(HWND, HWND, char *data, char *parms, BOOL, BOOL) {
  
	TestMap["#Channel"] = "Mark";

	_fstrcpy(data, TestMap.find("#Channel"));

	return3;
}


but just gives me loads of errors and warnings on the export function, any ideas what im doing wrong guys?

Last edited by pouncer; 21/01/06 03:36 AM.
#139750 21/01/06 11:43 AM
Joined: Jan 2003
Posts: 249
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
first thing

http://www.sgi.com/tech/stl/table_of_contents.html

Next

Code:
typedef std::map&lt;std::string, std::string&gt; MyMap;
MyMap TestMap;

//export function..

extern "C" int WINAPI Test(HWND, HWND, char *data, char *parms, BOOL, BOOL) {

  std::string chan( "#Channel" );
  std::string mark( "Mark" );

  TestMap.insert( MyMap::value_type( chan, mark ) );

  MyMap::iterator it = TestMap.find( chan );

  if ( it != TestMap.end( ) ) {

    lstrcpy( data, (*it).second.c_str( ) );
  }

  return 3;
}


Little explanation :

You need to have your insert types to be the same as defined in your map. Strings like "blah" are C-Strings and not std::string onjects. Next you insert like demonstrated which adds the item in the map (the map is like a hash table, it's sorted as a binary tree (on the key) for fast access and search, there is no order).

When you use the find method on your map with a std::string as an argument which matches your defined map key type, it will return an iterator to the item. You need to check that this iterator isn't the end of the map (essentially pointing to NULL since it didn't find the item which you get by using .end( ) function to check the condition). An iterator is a pointer to an item. A map item has 2 properties, .first which is the "key" and .second which is the "data" and since these are atd::string, I need to retreive them as a C-String to be able to copy the value into the char * data that mIRC gives.

Note: I'm not a fan of using the "use namespace std;" as I prefer to typedef my items instead as your are sure your "string" or "map" come from STD and not another library.

Last, if you are really interested in STL, you should ditch the DLL for now and concentrate on understanding it with a simple console application to test how it works and be confortable with iterators and the such (the whole STL works in every object the same way).

#139751 21/01/06 12:12 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
thanks alot david, im gona do what you said and mess about with things in a console, thanks for the code and explanation, just the kind of reply i needed!!

#139752 21/01/06 12:24 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
i got this code, with a little problem

Code:
// hhh.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include &lt;map&gt;
#include &lt;string&gt;
using namespace std;

typedef std::map&lt;std::string, std::string&gt; MyMap;

// MyMap TestMap; - As soon as i uncomment this line, it compiles fine :S

int main() {

	std::string chan( "#Channel" );
	std::string mark( "Mark" );


	return 0;
}


that MyMap TestMap is causing problems, but when i comment it, it compiles fine, but i need it for this to work right?

Last edited by pouncer; 21/01/06 12:59 PM.
#139753 21/01/06 04:19 PM
Joined: Jan 2003
Posts: 249
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
you got 2 choices. or you comment the "using namespace std" line and use std:: in front of all the types that need it OR you uncomment the line and remove std:: in front of all the types that need it.

A namespace is a realm in which the code is defined.

you can define some code in a namespace like this

namespace blah {

typedef bloh int;
}

blah::bloh myvar = 4;

if I insert this

use namespace blah;

then I can only use

bloh myvar = 4;

#139754 21/01/06 05:20 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
ok nice one, made a fair bit of progress thanks to you but this is a bit shocking. The below code gives 0 errors, but 121 warnings LOL. and also, it prints Mark twice (in the exe window) where it should print Mark, and then Harry, as I changed the data from mark to harry

Code:
// hhh.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include &lt;map&gt;
#include &lt;string&gt;
using namespace std;

typedef std::map&lt;std::string, std::string&gt; MyMap;
MyMap TestMap;

int main() {

	std::string chan( "#Channel" ); //keytype
	std::string mark( "Mark" );     //datatype

	TestMap.insert( MyMap::value_type( chan, mark ) );
	MyMap::iterator it = TestMap.find( chan );
	//this should print Mark
	if ( it != TestMap.end( ) ) {
		printf( (*it).second.c_str( ) ); 
		printf("\n");
	}

	//change #channel value from Mark to Harry
	TestMap.clear;
	std::string harry( "Harry" );
	TestMap.insert( MyMap::value_type( chan, harry ) );

	//this should now print Harry
	if ( it != TestMap.end( ) ) {
		printf( (*it).second.c_str( ) );
		printf("\n");
	}

	return 0;
}


Last edited by pouncer; 21/01/06 05:20 PM.
#139755 21/01/06 07:40 PM
Joined: Jan 2003
Posts: 249
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
I think you misunderstood me on the "using namespace std;"

if you use it, you have to omit the std:: in front of the types you use that come from the library. If you don't, you have to insert them in front or the system will say he can't find the type you are using.

And .clear( ) is a function not an argument. I compiled this code on VC++2003 and it works like a charm and prints the names correctly.
Code:
#include &lt;stdio.h&gt;
#include &lt;map&gt;
#include &lt;string&gt;


//using namespace std;

typedef std::map&lt;std::string, std::string&gt; MyMap;

MyMap TestMap;

int main() {

	std::string chan( "#Channel" ); //keytype

	std::string mark( "Mark" );     //datatype

	TestMap.insert( MyMap::value_type( chan, mark ) );

	MyMap::iterator it = TestMap.find( chan );

	//this should print Mark

	if ( it != TestMap.end( ) ) {

		printf( (*it).second.c_str( ) ); 

		printf("\n");

	}

	//change #channel value from Mark to Harry

	TestMap.clear( );

	std::string harry( "Harry" );

	TestMap.insert( MyMap::value_type( chan, harry ) );

	//this should now print Harry

	if ( it != TestMap.end( ) ) {

		printf( (*it).second.c_str( ) );

		printf("\n");

	}

	return 0;

}

#139756 21/01/06 09:05 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
:S this is very odd then, im doing something badly wrong then because I get

Linking...

hhh.exe - 0 error(s), 122 warning(s) which prints Mark twice in the c:\hhh\hhh.exe debug exe when i click on

execute hhh.exe from the build menu :S

(im using the exact code you pasted)

the version im using is visual c++ 6.0, and its all in a win32 console application, hope someone can tell me if im doing anything wrong, i really would like to get this working, thanks guys

Last edited by pouncer; 21/01/06 09:37 PM.
#139757 21/01/06 10:33 PM
Joined: Jan 2003
Posts: 249
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
try putting this at the top

#pragma warning( disable : 4530 )

I know the STL is a little hippy about warnings sometimes.

But I can't see what you are doing wrong, make sure you use the code I provided. Could also be your compilator (or mine) which doesn't compile stuff the same way.

#139758 21/01/06 10:54 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
d*mn, stil the same problem,

i dont know what to do now :S

if its not of any hassle david, is there any chance you could upload the project you made it in as a zip, so i can see if it compiles on mine?

Last edited by pouncer; 21/01/06 10:59 PM.
#139759 22/01/06 02:47 AM
Joined: Jan 2003
Posts: 249
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
the whole code I have, I already posted it, there is nothing more.

#139760 22/01/06 01:50 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
is there any chance you could see if this compiles for you please mate?

www.geocities.com/pouncer_123456/hhh.zip

thanks david

#139761 22/01/06 03:00 PM
Joined: Jan 2003
Posts: 249
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
Remake a new project and select "Empty project" instead of the choice you made that includes precompiled headers (the stdafx.h .cpp files which you really don't need and may be causing more harm than good in your case).

I never use them either.

#139762 22/01/06 04:20 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
ok thanks, ive dont exactly that, and for some reason it gives me 123 warnings still (and stil prints the names wrong), you can see it in the build log and heres the small project

www.geocities.com/pouncer_123456/testNew.zip

the code is exactly the same as yours, its kind off spoilt all the plans i had for this dll, i cant do anything now :S

i noticed many of those errors had this in it

c:\program files\microsoft visual studio\vc98\include\map

heres the map file which i found in that directory, not sure if there might be a problem with that

http://www.geocities.com/pouncer_123456/map.txt

Last edited by pouncer; 22/01/06 04:27 PM.
#139763 22/01/06 04:31 PM
Joined: Jan 2003
Posts: 249
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
remove that ; after the first #include

and I said clearly that TestMap.clear is a function not an attribute and should be

TestMap.clear( ); <----

The rest compiles fine here, noe warnings or errors and returns

Mark
Harry

I think you aren't too familiar with C programming to make these kinds of omissions, maybe you should invest time to learn C/C++ before trying to tackle this type of problem which is obviously a little intermediate to advanced stuff. This demo is simple, but it can get ugly quickly if you want to add more stuff to it.

#139764 22/01/06 06:48 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
ok, corrected both of those things you said, still the 123 warnings (no errors though)

and prints names wrong

i give up, i dont know why an earth this is happening, must be the map class on my pc or something?

erm hangon, are you only compiling it from the 'build' menu?
i got 0 error, 0 warning when i did that

but when i click on 'rebuild all' thats where all the warnings come up

Last edited by pouncer; 22/01/06 06:55 PM.
#139765 22/01/06 07:26 PM
Joined: Jan 2003
Posts: 249
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
I get 0 errors when I rebuild all, build, or any other compile options.

You should try to install SP4 of Visual Studio 6 and also the latest SDK with the latest libs.

#139766 22/01/06 11:36 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
yeah ok thanks, im just hoping its a problem with my c++ version installed or something.

Ill try reinstalling it some other time now, but just lie to say a big thanks to you david on this thread.

#139767 24/01/06 10:36 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
sorry for bringing this thread back david but just a quick Q,

Code:
#include &lt;string&gt;
using namespace std;
typedef map&lt;string, string&gt; MyMap;
MyMap TestMap;


i removed the std::'s, as im 'using namespace std', but it just keeps saying

error C2143: syntax error : missing ';' before '<'

like 4 times :S

#139768 24/01/06 11:04 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
If you want to use a map, you need to include the header for it:

#include <map>


Gone.
#139769 24/01/06 11:38 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
ok thanks sorted that part, got it about 90% working now. but im trying to return an entry in a seperate function (and storing an entry in another function)

Code:
	string channel = data;
	iT = KeyStorer.find(channel);

	string key = (*iT).second.c_str( );

	_fstrcpy(data, key.c_str());
	return 3;


as you see above the data is the channel name i ffed into the dll parameter, keyStorer is the map instance name, its definately storing the key, but its just crashing my mirc when i use the above code to grab the key, any ideas guys?

ive got all this stored at the top

typedef map<string, string> MapFunction;
MapFunction KeyStorer;
MapFunction::iterator iT;

Last edited by pouncer; 24/01/06 11:39 PM.
#139770 25/01/06 02:43 AM
Joined: Jan 2003
Posts: 249
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
Code:

string channel = data;

MapFunction::iterator it = KeyStorer.find( channel );

if ( it != KeyStorer.end( ) )
 lstrcpy( data, (*it).second.c_str( ) );
else
  lstrcpy( data, "Key Not Found" );

return 3;

#139771 25/01/06 02:53 AM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
thanks for the reply, this is very weird. heres the code

Code:
//stuff at the top for maps etc
typedef map&lt;string, string&gt; MapFunction;

MapFunction KeyStorer;
MapFunction::iterator iT;

extern "C" int WINAPI StoreKey(HWND, HWND, char *data, char *parms, BOOL, BOOL) {

	string channel = GetTok(data, 1, 32);
	string key = GetTok(data, 2, 32);

	KeyStorer.insert(MapFunction::value_type(channel, key));

	return 1;
}

extern "C" int WINAPI GetKey(HWND, HWND, char *data, char *parms, BOOL, BOOL) {

	string channel = data;
	MapFunction::iterator it = KeyStorer.find( channel );

	if ( it != KeyStorer.end( ) ) 
		lstrcpy( data, (*it).second.c_str( ) );
	else  
		lstrcpy( data, "Key Not Found" );
	
	return 3;
}


//.dll Test.dll StoreKey #hello testkey

then

//echo -a $dll(Test.dll, GetKey, #hello) - should echo testkey but it just echos 'no key found' :S

Last edited by pouncer; 25/01/06 03:01 AM.
#139772 25/01/06 10:51 AM
Joined: Jan 2003
Posts: 249
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
then I'm sorry to say that your code to insert is flawed with that Gettok stuff

Look at your insert params to see what is going on

#139773 25/01/06 01:31 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
but it works like this...

Code:
extern "C" int WINAPI StoreKey(HWND, HWND, char *data, char *parms, BOOL, BOOL) {

	string channel = GetTok(data, 1, 32);
	string key = GetTok(data, 2, 32);

	KeyStorer.insert(MapFunction::value_type(channel, key));

	MapFunction::iterator it = KeyStorer.find( channel );

	if ( it != KeyStorer.end( ) ) 
		lstrcpy( data, (*it).second.c_str( ) );
	else  
		lstrcpy( data, "Key Not Found" );
	
	return 3;
}


//echo -a $dll(Test.dll, StoreKey, #channel key) echos key

but it just doesnt return the key from a seperate function :S

Last edited by pouncer; 25/01/06 02:31 PM.
#139774 26/01/06 12:03 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
seeing as im having problems with using the .insert and .find in seperate functions (and it works when i put both in 1 function) could the problem be the loading and unloading of the dll?

if i call the storekey function to store the key for the specified channel, and the dll unloads, would the dll loose all its contents?

its the only reason i can think of, why the getkey doesnt return the value, maybe because the dll is unloading?

#139775 26/01/06 01:01 PM
Joined: Jan 2003
Posts: 249
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
yes it would

you can force mIRC to keep the DLL loaded all the time, in the unload function

// mIRC wants to close the DLL because /dll -u was called or mIRC exits
if ( timeout == 1 ) {

//clean your stuff here
return 1; // <-- tell mIRC it's ok to unload
}
else
return 0; // <-- tell mIRc we don't want to unload due to idling DLL usage (we want to keep it in memory until it's forced to unload or mIRC's exits)

Now I would really recommend that you build yourself functions to echo some debug messages to mIRC while you develop your stuff. You can take a look in the DCX package for something like mIRCError which will send the contents to mIRC via an //echo -s so I can see stuff that is going on inside the DLL during operations and manipulations to anticipate problems with data structure, invalid params, etc.

us it with the combination of wsprintf() or lstrcpy()

I would suggest you stick with the lstr* functions because they are natively included in the windows API base stuff. Using strcpy or any other variant not lstr* will only add to the size of your DLL as this extra code will be packaged with it. wsprintf() is part of the lstr* functions included.

char error[900]; // <-- no more than 900 because mIRC's data parameter which you will copy the value to send it to mIRC is limited to 900 chars.

int param1 = 12;
char [] blah = "Error occured";
wsprintf( error, "%s : %d", blah, param1 );

mIRCError( error ); // <-- assuming you use the same function is use

Debugging tools are your best bet to help you understand what is going on.

Secondly, I developped a small string library which might interest you, it's in the DCX source code if you can find that online. It's called TString which basically replicates what string does, but it adds the *tok functionality to it so it is easier to parse the parameters passed to a function. You can look into the DCX source code for examples on how to use it.

If you want, I can send you the latest version of that TString library which has quirks fixed (maintained by a friend Ook on IRC). I'm usually online at night or send me a pmsg with your e-mail and I'll send over the library.

#139776 26/01/06 08:55 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
thanks alot david, I've sent you a private message, hopefully I can use your tsring library for parsing now.

also, about this unload function

Code:
extern "C" int WINAPI UnloadDll(int timeout) {
	if ( timeout == 1 ) {
		return 1;
	}
	else return 0;
}


so mIRC wil always call this function when unloading the dll, and instead, keep the dll loaded?

another thing, i download your dcx dll stuff from mircscipts.org, the source folder seems to be empty though, i'll talk to you online, maybe soon, thanks!!

i just tried it, and after i made a call to the dll, i did this

//echo -a $dll(0) which echos 2 (2 other dlls loaded with my script)

it should be 3, which means the dll is unloading :S

(I did also put UnloadDll in exports file)

Last edited by pouncer; 26/01/06 10:34 PM.
#139777 26/01/06 10:47 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
never mind, ive fixed..
the problem is now about 99.9% sorted

the dll now doesnt unload so it stores all the info so this works

//.dll Test.dll StoreKey #channel David

//echo -a $dll(Test.dll, GetKey, #channel) echos david

but something strange happens when i do this.. :S

//echo -a $dll(Test.dll, GetKey, hello) = hello
//echo -a $dll(Test.dll, GetKey, #hello) = #hello

whatever i put there, it echos the param i put in, but these params dont even exist in a map :S

i only added '#channel' to the map

Last edited by pouncer; 26/01/06 10:50 PM.
#139778 26/01/06 10:59 PM
Joined: Jan 2003
Posts: 249
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
it's because mIRC's data parameter in the function is used for input and also output.

Once you have finished garnishing the data you need in data, reset it simply by doing

data[0] = 0;

then proceed with your normal stuff, if a match is found in the DLL your copy functions will overide this, else, the dll will return an empty string which is equivalent to $null in mIRC.

#139779 26/01/06 11:05 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
thanks very much david.

#139780 27/01/06 12:00 AM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
just another quick question mate,

Code:
	int __stdcall StoreKey(HWND, HWND, char *data, char *parms, BOOL, BOOL) {

		string channel = GetTok(data, 1, 32);
		string key = GetTok(data, 2, 32);

		KeyStorer.insert(MapFunction::value_type(channel, key));

		return 3;
	}


is there a way to clear that channels value? instead of doing something like

KeyStorer.clear() //removes all the map keys

problem i have is this:

//.dll Test.dll StoreKey #mIRC coolchannel
//echo -a $dll(Test.dll, GetKey, #mIRC) = coolchannel
//.dll Test.dll StoreKey #mIRC nicechan
//echo -a $dl(Test.dll, GetKey, #mIRC) = coolchannel

it isnt replacing the original value for the channel, in the map

Last edited by pouncer; 27/01/06 12:00 AM.
#139781 27/01/06 12:16 AM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Code:
KeyStorer.erase(channel);
KeyStorer.insert(MapFunction::value_type(channel, key));

#139782 27/01/06 12:53 AM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
thanks hixxy, tried it, still the same problem

//.dll Test.dll StoreKey #mIRC coolchannel
//echo -a $dll(Test.dll, GetKey, #mIRC) = coolchannel
//.dll Test.dll StoreKey #mIRC nicechan
//echo -a $dl(Test.dll, GetKey, #mIRC) = coolchannel

Last edited by pouncer; 27/01/06 12:53 AM.
#139783 27/01/06 03:54 AM
Joined: Jan 2003
Posts: 249
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
MapFunction::iterator it = KeyStorer.find( channel );

if ( it != KeyStorer.end( ) )
KeyStorer.erase( it );

#139784 27/01/06 09:19 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
nice one david

Page 1 of 3 1 2 3

Link Copied to Clipboard