
keitsi
Avatar/Signature-
Posts
30 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by keitsi
-
I haven't noticed labels being very slow. What OS are you running on what processor/how much RAM? On win98se I have noticed all the graphics stuff being very slow.
-
TreeView doubleclick-expand hack Here. http://www.xtremedotnettalk.com/showthread.php?p=424382#post424382
-
VB.NET code to prevent Expand() and Collapse() from firing when TreeView is doubleclicked. Add this class to your project: 'DoubleClick-expand restriction hack Public Class cTreeViewDblClickHack Private WithEvents m_tv As TreeView Public Sub New(ByVal tv As TreeView) m_tv = tv End Sub Private m_FirstMouseDownTime As Long Private blnDoubleClick As Boolean = False Private Sub tv_BeforeExpand(ByVal sender As Object, _ ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) _ Handles m_tv.BeforeExpand If blnDoubleClick AndAlso e.Action = TreeViewAction.Expand Then e.Cancel = True Else m_FirstMouseDownTime = 0 End If End Sub Private Sub tv_BeforeCollapse(ByVal sender As Object, _ ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) _ Handles m_tv.BeforeCollapse If blnDoubleClick AndAlso e.Action = TreeViewAction.Collapse Then e.Cancel = True Else m_FirstMouseDownTime = 0 End If End Sub Private Sub tv_MouseDown(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles m_tv.MouseDown If Now.Ticks - m_FirstMouseDownTime <= (SystemInformation.DoubleClickTime * TimeSpan.TicksPerMillisecond) Then blnDoubleClick = True Else blnDoubleClick = False End If m_FirstMouseDownTime = Now.Ticks End Sub End Class And use it in your Form like this: Private m_TreeViewDblClickHack As cTreeViewDblClickHack Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call m_TreeViewDblClickHack = New cTreeViewDblClickHack(Me.tv) End Sub TreeView is an annoying piece of **** :( I got the idea from here: http://www.windowsforms.net/Forums/ShowPost.aspx?tabIndex=1&tabId=41&PostID=15689
-
Just add the method to a class - then call it using MessageBox.Show(ClassNameWhereTheMethodIsIn.RandomLetters(10)); for example. The method is static and must be used without class initialization (straight from class, not object). There's not much to implement, just use the function ;) Oh and this can only generate lowercase letters. You'll have to modify it to suite your needs. Also, the ASCII range might be wrong for 1 or two bytes, I haven't tested this function enough.
-
Here is my implementation. I didn't use Const for those few variables for mono compability (because of this bug). /// <summary> /// Generates given count of random lowercase letters /// </summary> /// <param name="count">How many letters to generate</param> /// <returns>String of generated letters</returns> public static string RandomLetters(int count) { byte[] bytes; bytes = new byte[count]; System.Security.Cryptography.RandomNumberGenerator rnd = System.Security.Cryptography.RandomNumberGenerator.Create(); rnd.GetBytes(bytes); byte min=97; // ascii range: 97 (a) - 122 (z) byte max=122; int range = max - min + 1; float rangefactor = ((float) range) / 255; // letter ascii code range (~28) against 0 - 255 -> 0,something byte[] newbytes = new byte[count]; for (byte k=0;k<bytes.Length;k++) { newbytes[k] = System.Convert.ToByte(((((float) bytes[k]) * rangefactor) + (float) min)); } string str = System.Text.ASCIIEncoding.ASCII.GetString(newbytes,0,newbytes.Length); Debug.WriteLine("RandomLetters() returning '" + str + "'"); return str; }
-
I used the following solution, with two seperate binaries: - Main program EXE - Autoupdater EXE The autoupdater uses HTTPS to download binaries from HTTPS server, which address/user/pass are hardcoded into the program. I use mentalis.org's SSL library and wrote my own HTTP implementation for it. The https server contains files named: "autoupdate.txt" - contains the latest version number "changelog.txt" - the changelog of all versions "installer_v_X_X_X_X.exe" - where X_X_X_X is the version number contained in autoupdate.txt - the autoupdate program downloads autoupdate.txt - it compares the version to installed version (detection based on filename - every binary ends with v_X_X_X_X) - If newer version available, downloads changelog.txt, prompts if we should download the latest version (shows the changelog in same message) - downloads the binary - detects if an instance of main app is running (using Process.GetProcesses()), prompts user to close them until no running processes detected. - Runs the installer program and immediately closes itself. Here is the source code for my mentalis.org HTTPS downloader implementation: http://lappi.skai.fi/~mikkoko/csharp/https_downloader_implementation.zip
-
I got that impression also - shouldn't GC take care of those after they are finished? If you want to be sure, test it... create 30 test threads which all takes some amount of memory, make them run for 1 minute and see if the memory usage drops after they are finished.
-
Take a look at FileStream and StreamWriter on MSDN. Most of that kinda stuff are in seperate classes now and should be used instead of legacy VB calls. http://www.xtremedotnetalk.com/showthread.php?t=79977&highlight=binary+file
-
Tbh we though of something like that when we started to design the system - we came in to conclusion that it would have been too complex to implement in the given time. The fact that you can decompile .NET IL _SO_ easily came in to knownledge later, this was also another reason why we didn't design it to be a "dumb client viewer" with server-side permission checks. Sounds fair enough - didn't even think of a solution like that. Let me get it straight: - you login to the authentication DB using some default username and password, which could be stored for example in C++ DLL - once connected to SQL, you select the "real", encrypted username and password from some table, which are same for every user (?) - you decrypt the retrieved login & pass (maybe this could also be done calling a C++ DLL) and login to the "real" DB Damn I'm tired, not sure if I got it all right :) ..sounds good anyway. In the other hand, what's the point in C++ DLL calls if you can discover the entrypoint name in 30 seconds. For now, I will be satisfied with "somewhat" secure solution. Most likely the people using this application won't know much of programming. If hacking the login&password is even somewhat complicated, there probably (hopefully) won't be any hackings ;) I already implemented a "hidden" C++ DLL call, with a pointer to byte[] Key, which manipulates the hardcoded crypt key a bit. The method lyes "camouflaged" with other unrelevant code and is called when application is started. Maybe by filling the app with stuff like this will make it frustrating enough to prevent potential hackers from bothering. Hehe, am I pathetic enough? I guess committed C++ coders would make a good laugh of this :P I'm kind of disappointed in .NET in this matter. :( Well thanks for the answers, hopefully I figure this out.
-
Hi. I am aware of the matter that you can decompile IL code back to very readable C#/VB.NET. After a though I don't give a crap if someone takes a peek at the source code, because probably he could do it in the same time by writing a new one from scratch. Also understanding and being able to alter the code in a working fashion would require some time. I am more concerned about storing DB passwords and Private Keys. At the moment it happens this way: - SQL password is in seperate config file crypted with 3DES (192) - Private Key and IV used by 3DES are hardcoded in binary file (the main EXE in IL) Ok, when the applicaiton starts, password required by SQL server is decrypted from the encrypted password. Even if I store the PK in seperate C++ DLL, you could easily retrieve it by: - attaching a debugger to the running project (right?) - decompiling the IL and finding the entrypoint name used to retrieve PK Anyone know of a secure enough way to do this? I am not concerned about someone using assebler to retrieve the PK since that would require significantly bigger effort, and that would be possible even if the application was fully written in C++. Obfuscating the IL code probably wouldn't help much since I'm not concerned about someone looking at the source; PKs are the most important matter. The program is written in VB.NET and some modules in C#. Program uses ByteFX's MySqlClient (written in C#) for MySQL communication. Making it hard for someone to crack the SQL password would be very neat. I have some C++ exprience and I think writing a C++ DLL would not be big effort. Thanks in advance if someone is able to guide me a bit. What methods would you recommend?
-
I've also noticed this behavior. You could use arraylist to keep the order? I mean like adding the keys to arraylist in the order they were added, then Return Me(arraylist(index)) That takes up a bit more memory though.
-
IRC example Don't know if there are good IRC client examples for VB.NET, but I would rather start off by learning how to use TCP sockets with VB.NET. Some basic listen/connect examples. Search MSDN for "TCPListener" for example. Then, find some example that shows you how the IRC protocol works and implement it to your own VB.NET app. I've seen few for VB6 at least. I bet no one has the time to write you an example IRC app for VB.NET Luck :) EDIT: okay, few hits with google: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=810&lngWId=10 http://weblogs.asp.net/cumpsd/articles/79260.aspx
-
You really could think on your own too ;) Private bCloseButtonClicked As Boolean = False Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If bCloseButtonClicked Then Return 'close immediately without asking End If If MsgBox("Shall we quit?", MsgBoxStyle.YesNo + MsgBoxStyle.Exclamation, "Confirmation") = MsgBoxResult.No Then e.Cancel = True End If End Sub Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click bCloseButtonClicked = True Me.Close() End Sub
-
:P Yeah, everythink works for me too except few annoying bugs in the VB.NET compiler GUI itself.. well, at least I seem to be annoyed of them :) I'm just wondering if there's any way to keep the compiler & MSDN up to date with Win2k SP4. If I can't install any service packs, I will never get rid of them? Looks like a good time to buy XP license ;)
-
I have Win2k service pack 4 installed and I am being unable to install .NET service packs nor MSDN updates. Just get a "wrong version" error (or something like that, it was in finnish). Seems that Windows 2000 SP4 is not supported by .NET service packs. Here are the patches I tried to install: http://msdn.microsoft.com/netframework/downloads/updates/sp/default.aspx http://www.microsoft.com/downloads/details.aspx?FamilyID=2eaeb501-c197-4892-9c50-8f6be1b0d4e0&displaylang=en Both give the same error. Maybe I already got the latest versions from win2k SP4? Seems illogical to me, that the VB.NET IDE service packs would come with windows updates. Here's what versions I have installed (typed from the VB.NET About window) Microsoft Development Environment 2003 Version 7.1.3088 Microsoft .NET Framework 1.1 Version 1.1.4322 Maybe someone could illuminate me? :)
-
Problem connecting to MySql server from VB
keitsi replied to mihaiguran's topic in Database / XML / Reporting
ByteFX (with LGPL license) or MySQLDriverCS (with GPL license) pwns ODBC with the MyODBC-client. ;) You don't even need to have MyODBC installed. Also, using MyODBC in commercial environment is illegal (says MySQL Ab). I found it much better way to use the ByteFX client. Maybe you could try MySQLdriverCS if your app is open source, I've seen few people say that MySQLdriverCS is better. I'm using ByteFX and works fine for me. Plus, it's LGPL and I for sure can use it legally in commercial apps. http://www.bytefx.com/ http://sourceforge.net/projects/mysqldrivercs/ -
http://www.xtremedotnettalk.com/showthread.php?t=71433 http://www.dotnet247.com/247reference/msgs/4/21219.aspx "Description" and "IPAddress" might be what you are looking for? just use them instead of "MACAddress"
-
If anyone needs an alternative and light SQL command builder, here's one I originally wrote for VB6 and now ported to .net. Easy to use, no known bugs and example projects included. Designed for MySQL 3.23 syntax. http://lappi.skai.fi/~mikkoko/vbmodules/SQLCreatorClasses_vb_net_bundle_v_1_01.zip
-
Programming Method - How are you getting around with it ?
keitsi replied to Arch4ngel's topic in Water Cooler
I'd be 3 ...but often I am being forced by the client (the guy who got the $'s (actually euros)) to speed up developement: they want to see the program running - no matter how good it was planned. Not like I was doing it too slowly (coding about 12 hours per day nolife) but for example this project I'm currently working with was ordered like a year ago. :) The previous coder failed few other projects badly (let's say the VB6 code was some peace of crap - nevaheard of classes, copy-pasting code rocks!), and now the clients are shimmering my *** for his inability (bugs, crashes, database is all messed, missing options that were in the contract etc). Now it's looking a bit lighter since most of the old crap projects' bugs are fixed (temporary solutions, just to make it work until I do a rewrite) and apps are somehow working, in use by the end users. Now I got my chance create & plan something of my very own - this rewrite of one of the older apps would definitely be 3... You have no idea how good the inherited classes & stuff feel after 4 months of fixing someone else's bugs. ;) Though, I just got a call from the client that they would like to see some testable beta this weekend... need to speed up things a bit and finish the mysql table structure quickly, so they can see what they want. *sigh* Enough crap talk for tonight, back to coding -> edit: euro char not showing up -
Thanks, didn't notice that function. Yes, I'm working with libMySQL.dll which returns uints. Haven't tried though if Int64s work (return values will get screwed?).
-
This is not a problem, it's easily skipped by converting them to Int64's... but I'm just wondering what's the cause of this :P I don't get it :) You can't compare two integers of the same type, but you can first convert them to signed 64bit and then compare. Anyone else bumped to this?
-
Hmm, isn't mysql GPL or $495, depending if your app is opensourced or not. http://www.mysql.com/products/licensing/
-
In any public module Sub Main() dim frm1 as new Form1 frm1.Show dim frm2 as new Form2 frm2.Show Application.Run 'prevent app from exiting End Sub EDIT: hmmm, whooops.. Sorry, I accidentally woke up this ancient thread :P
-
mysql 3.23 on linux, access only when I'm forced to :)
-
I came out with this function based on the code found from http://www.dotnet247.com/247reference/msgs/4/21219.aspx I use this to create computer specific md5sum for identifying. Btw you need to add System.Management reference to your project. Imports System.Management Public Function GetFirstMac() As String 'returns the mac address without :'s for first network adapter found 'returns "" if none found Const sQuery = "SELECT MacAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = true" Dim oRet As ManagementObjectSearcher = New ManagementObjectSearcher(sQuery) Dim MCol As ManagementObjectCollection = oRet.Get() Dim MObj As ManagementObject Dim MacNow As String For Each MObj In MCol Debug.WriteLine(MObj("MacAddress")) MacNow = MObj("MacAddress") If (Not IsNothing(MacNow)) Then MacNow = Replace(MacNow, ":", "") If Len(MacNow) = 6 * 2 Then '6 x hex Return MacNow End If End If Next Return "" End Function