|
you can't, that's what 'random' means.
To do what you want, build a list of 16 ints, 0-15. Get a random number from 0-15 and pull that index out of the array. For your next number, get a random digit between 0 and 14. And so on.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
Christian Graus wrote: To do what you want, build a list of 16 ints, 0-15. Get a random number from 0-15 and pull that index out of the array. For your next number, get a random digit between 0 and 14. And so on.
That wouldn't help much because even if you reduce the number each time, you can still get the same number multiple times (if the first Next() returns 3, nothing stops the next call of the method to return 3 again).
You should save the numbers in a generic List, because it has a variable amount of items and you can still access the items by int indexes.
Then call Next() and after getting the value from the list, remove the index that just has been generated by Next (you need to save its result in some variable).
For the next step, you'd need to create a new random with the changed count of the now smaller List as seed (why can't you change the seed of a random after it's been created anyway?).
|
|
|
|
|
Hi all.
How can i hide the mail address of the "sender" of a mail in C#?
Thanks.
|
|
|
|
|
How do you mean ? If you're sending the mail with C#, then you can specify whatever sender you like.
I assume you're writing some sort of hostile mail bomb or spam program. Why do you want people to hate you ?
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
I read it the same way. If he doesn't understand something that trivial, he'll get nailed for sure!
|
|
|
|
|
What you are asking for is not possible. An email message has to have a sender.
You can put any sender address you like in an email message, then it depends on your mail server what addresses it allowes as sender.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks for the replays.
The problem is this:
I've made a software for save password,and i've insert in it a service "password recovery" thath send a mail with the password of the account (if the user have insert it).For this i'm using my gmail account.
But i've try to send a mail to me (to another address, and so i've see that the user can see my mail address).
How can i avoid the problem?
If i have to create another mail account,can you advice me what service to use? (a free service that i can use with C# and i can block the replay).
Thanks.
Ps:sorry for bad english.
|
|
|
|
|
I have a table that I want to display one column to a user for viewing only via a windows form. What is the easiest way to display this data?
I was looking at the DataGrid, but I am not sure how to load this. Any sample code or articles on this componet would be great.
Thanks!
|
|
|
|
|
Just do a search of the articles on this site for something like "Bind data AND grid", and I'm sure you will find multiple examples.
|
|
|
|
|
Set the datasource of the grid and call the databind method. Look for some articles for more info on how to format the data.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
First of all let me apologize for posting this without searching about it first.
I'm doing this because I'm in a hurry and I need to leave my work right now, and I was in the middle of this problem.
Well I'm starting on p/invoke just now and I can't make it work.
I created a class with all methods I need to call from the dll and it looks something like this:
[DllImport(@"MitraLib.dll", EntryPoint = "MitraConectaBD", CallingConvention = CallingConvention.StdCall)]
public static extern int MitraConectaBD(IntPtr AsUsuario, IntPtr AsSenha, IntPtr AsBanco, bool AbLoginPrompt);
Well, with the class created I started to code what I wanted:
public Form1()
{
Thread.CurrentThread.Name = "MAIN";
InitializeComponent();
IntPtr ptrLogin = Marshal.StringToHGlobalAnsi("oscar");
IntPtr ptrSenha = Marshal.StringToHGlobalAnsi("1");
IntPtr ptrDataBase = Marshal.StringToHGlobalAnsi("Gerencial2000i");
int retCode = MitraLib.MitraConectaBD(ptrLogin, ptrSenha, ptrDataBase, false);
Marshal.FreeHGlobal(ptrLogin);
Marshal.FreeHGlobal(ptrSenha);
Marshal.FreeHGlobal(ptrDataBase);
}
Well, when I try to compile my project I get an exception saying
(translated to english by myself)
It wasn't possible to load the DLL 'MitraLib.dll': It wasn't possible to find the specific module(Exception HRESULT: 0x8007007E)
or something like that.
Does anyone have any clue?
I'm sorry again for posting this withou searching the forum (although I googled it but didn't find anything)
ps. MitraLib.dll is a Delphi code.
Thanks in advance
Oscar
|
|
|
|
|
Not sure, but try removing the namespace:
int retCode = MitraLib.MitraConectaBD
|
|
|
|
|
Hi there!
Thanks for the attention.
But no, that didn't work. When I remove MitraLib the method MitraConectaBD stops belonging to the current namespace!
I forgot to tell on my first post: My MitraLib.dll file is already in bin\Debug and in bin\Release folders.
Also, in the project properties, the output path in in Build tab is already set to bin\Debug
But still doesn't work...
Is there any extra configuration I should make to work?
Thanks again!
|
|
|
|
|
Another thing,
I've just copied MitraLib.dll to my system32 folder and now it works!
But how can I make it search in bin\Debug ?
Thanks again!
|
|
|
|
|
Make sure you have MitraLib.dll in a folder where the compiler can find it. I'd try to have it in the same folder as your source code or C:\Windows\System32. Be aware that you may need to put it in your <project folder="">/bin/Debug folder if you want to run and debug the project.
|
|
|
|
|
Hi Kythen, thanks for the answer!
I forgot to tell on my first post: My MitraLib.dll file is already in bin\Debug and in bin\Release folders.
Also, in the project properties, the output path in Build tab is already set to bin\Debug
But still doesn't work...
Is there any extra configuration I should make to work?
ps. Just copied MitraLib.dll to system32 folder and now it works!
How can I change the path of my project to search in bin\Debug??
Thanks again!
|
|
|
|
|
Hi,
this looks like a run-time error. Make sure your DLL is in a folder where Windows will look for it
(using PATH). Good candidates are: the folder holding your EXE (that would be a /bin/debug folder)
or C:\Windows\system32 (not recommended).
|
|
|
|
|
Hi Luc, thanks for the answer!
I forgot to tell on my first post: My MitraLib.dll file is already in bin\Debug and in bin\Release folders.
Also, in the project properties, the output path in Build tab is already set to bin\Debug
But still doesn't work...
Is there any extra configuration I should make to work?
ps. Just copied MitraLib.dll to system32 folder and now it works!
How can I change the path of my project to search in bin\Debug??
I can't let my application search in system32... it's not good for me...
Thanks again!
|
|
|
|
|
Hi,
AFAIK the EXE will look first in its own folder, only then use the Environment Variable "PATH" to
determine where to look next.
Be careful with outdated DLL copies.
I would suggest to remove all your DLL copies, and have just the one in the EXE folder itself.
Also make sure no older copies of your program are still running!
What is your OS?
|
|
|
|
|
Hi Luc,
I'm sorry but I don't know what 'AFAIK' is (I'm brazilian with a limited english knowledge)
Anyway, I assume that you meant that the default path search is exacly bin\Debug.
I've just removed my MitraLib.dll from system32 and have it only in bin\Debug and it is not outdated.
I find it funny that my project can't find it no mather what I do.
I'm googling since 9am and I can't find a way to force my project to look in bin\Debug...
I'm using windows XP
--------
LOL... I just got the brilliant idea to move every dll related with MitraLib.dll to the EXE folder and now it works fine... I though that the problem was not finding MitraLib... but it seems that the problem was that it couldn't find every dll related to it...
Anyway... I had to read alot about this... I think i'm a little better at p/invoke..
Now I can finally start developing.
Thanks for the help Luc!
|
|
|
|
|
As Far As I Know
you didn't mention multiple DLL files
once your EXE finds one somewhere, that DLL will look for whatever it needs
in its folder, not your EXE's folder.
yes the easiest approach is to have all your DLLs in your EXE folder.
you're welcome.
|
|
|
|
|
I have a list that holds many controls(e.g) Panels and a function that knows how to print a print form the list for a given index. I want to print 2 panels per page how can i build this algorithm.
|
|
|
|
|
I'd use the panels method that copies the control to a bitmap ( DrawToBitmap ? ), then write a print method that arranges those bitmaps as required.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
Sweet Zombie Jesus is this a hard problem to solve.
I'm making an IDE for a scripting language I made up and I want to borrow some of Visual Studio's manuerisms when it come to editing the properties of an object in a propertygrid.
I have a type called ScriptEvent. I want to completely emulate the behavior you see when you try and edit an event in VS. (Opens a document, scrolls to position, etc...)
If there is already a decent way. Please point me in that direction.
If there isn't a clean way, then how do I make a property in a propertygrid talk to a non-modal dialog to get a value....
|
|
|
|
|
Not sure if this helps, but have you looked at using the Visual Studio Shell[^]?
Life, family, faith: Give me a visit.
From my latest post: "A lot of Christians struggle, perhaps at a subconscious level, about the phrase "God of Israel". After all, Israel's God is the God of Judaism, is He not? And the God of Christianity is not the God of Judaism, right?"
Judah Himango
|
|
|
|