|
Hello Dave Kreskowiak,
Do you mean that I can found the solution from that website? I do try to copy the code there and paste to test but it can't works. They are using something call "Marshal" in the code but I don't know how it goes. Can you provide further solution on the issue?
Thanks
Regards
Drexler
|
|
|
|
|
The Marshal class provides methods, properties and attributes to tell the .NET CLR how to marshal parameters, among other things, back forth between managed and unmanaged code. An full explanation of how this works is well beyond the capacity of a forum post. It'd take something more like a small book to describe it all.
Can I ask why you're even bothering with these?? Most of these functions have equivilents in the .NET Base Class Library and some of the functions have been obsolete.
|
|
|
|
|
 Hello Dave Kreskowiak,
The following is the code I found from pinvoke, but there is a few error on it display on my Visual Studio 2003 developer tools:
Private Const MaxIniBuffer As Integer = &H7FFF<br />
<br />
Public Shared Function ReadSection(ByVal filename As String, ByVal section As String) As System.Collections.Specialized.NameValueCollection<br />
<br />
Dim pBuffer As IntPtr<br />
Dim bytesRead As Byte<br />
Dim sectionData As New System.Text.StringBuilder(MaxIniBuffer)<br />
<br />
Dim values As New System.Collections.Specialized.NameValueCollection<br />
Dim pos As Integer ' seperator position<br />
Dim name, value As String<br />
<br />
If (Not System.IO.File.Exists(filename)) Then<br />
Return Nothing<br />
End If<br />
<br />
' get a pointer to the unmanaged memory<br />
pBuffer = Marshal.AllocHGlobal(MaxIniBuffer)<br />
<br />
bytesRead = GetPrivateProfileSection(section, pBuffer, MaxIniBuffer, filename)<br />
<br />
If (bytesRead > 0) Then<br />
<br />
For i As Integer = 0 To bytesRead - 1<br />
sectionData.Append(Convert.ToChar(Marshal.ReadByte(pBuffer, i)))<br />
Next<br />
<br />
sectionData.Remove(sectionData.Length - 1, 1)<br />
<br />
For Each line As String In sectionData.ToString().Split(Convert.ToChar(0))<br />
<br />
' locate the seperator<br />
pos = line.IndexOf("=")<br />
<br />
If (pos > -1) Then<br />
<br />
' get values<br />
name = line.Substring(0, pos)<br />
value = line.Substring(pos + 1)<br />
<br />
' add to collection<br />
values.Add(name, value)<br />
<br />
End If<br />
<br />
Next<br />
Else<br />
values = Nothing<br />
End If<br />
<br />
' release the unmanaged memory<br />
Marshal.FreeHGlobal(pBuffer)<br />
<br />
' return collection or Nothing if we weren't able to get anything<br />
Return values<br />
<br />
End Function
First>>
Name "Marshal" is not declared.
Second>>
Value of type 'System.IntPtr' cannot be converted to 'String'.
Do you know how to solve this? I'm not really understanding how the flow of the data goes here in the above code.
Thanks~!
|
|
|
|
|
OK. All you needed was the Declare statements, not the entire page of code. The code is there only as an example fo using the function.
Marshal needs the System.Runtime.Interop namespace imported at the top of your code.
The second error comes up because, it's true, you're trying to pass an IntPtr variable where the function you're calling expects a string.
You don't need to do all this stuff. There's already libraries out there, like this one[^], that read/write .INI files without all this work.
|
|
|
|
|
Yeah,thanks Mr. Dave Kreskowiak. I have got what you mean now. Your solution is really helpful. Thank you so much.
Regards
Happy Programming everyone. 
|
|
|
|
|
<DllImport("KERNEL32.dll")> _
Public Shared Function GetPrivateProfileSection (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
End Function
Narender Sharma
|
|
|
|
|
hai frnds
i completed a project in vb.net 2.0 windows application
i stored a key in windows registry
this key is used to run the project
but this key is visible to all and they can use it to run the project
i have two choices
1)to make invisible the key in windows registry
2)store the key in differnt formats
but how many formats , what formats --- no should break my key and use it to run the project
the word "Format" is new to me
plz help me ...
if u know the solution for both the cases then plz sen to me....
thanks in advance
vijay
|
|
|
|
|
3) Encryption
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
vijaylumar wrote: i have two choices
No, you don't.
vijaylumar wrote: 1)to make invisible the key in windows registry
This isn't possible since the user wouldn't be able to run the applicaiton because he/she wouldn't be able to read the key.
vijaylumar wrote: 2)store the key in differnt formats
The different "format" would have to be an encrypted version of the key.
But, since you're putting this key in the regsitry, what's to stop the user from just exporting the data from the registry and importing it into another machine and running your app?? Nothing!! Since your key probably isn't generated from any machine specific data, your code will never know that it's an illegal copy.
Basically, any system you come up with yourself is going to be easily defeatable. Use a third party package instead. It's still no guarantee that your code won't be copied illegally, since any protection scheme can be cracked. Click here...[^]
|
|
|
|
|
hai frnds,
i completed a project with xml commenting
now i need a tool which produces me the complete Project Documentation.
i searched a lot in net but i found for vb.net 1.1
i need a tool which porducess Project Documentation in vb.net 2.0 windows application.
plz help me...
thanks in advance
vijay
devulapally_vijay@yahoo.co.in
|
|
|
|
|
you can see for NDOC (opensource) or sandcastle (opensource).
Il principe
|
|
|
|
|
Sandcastle[^] combined with Codeplex GUI. It's a great tool!
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
hi guys
i want to enable xml comments in my vb.net project created in vs-2005.
but when i type
(''') before my method declaration it doestnot show xml comment like c# why ?
hello
|
|
|
|
|
|
Hello,
It works fine when you add metadata above functions property,sub in your same application your work on but if you write a dll, add metadata and then use this dll in your application then it won't work correctly.
Any solution?
Thanks
Shay Noy
|
|
|
|
|
Why not? It works for me. It generates 2 separate xml files: one for the project and another for the dll.
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
perhaps it generates XML files but try to use from your application a function from your dll and you will see that no comment will be displayed.
Shay Noy
|
|
|
|
|
Not the case ... the comments are displayed
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
I found the problem why I can't see the comments when I am refering to functions of dll. All the dlls that we wrote are located on the network (I am working in factory ~ 500 persons). When I am using those dlls, I can't see the comments but if I am using the same dll while is located on my hard disk, I can see the comments.
How can I solve the problem while the dll is located on the net?
Thank you
Shay Noy
modified on Wednesday, April 23, 2008 1:55 AM
|
|
|
|
|
my question is ragard once user enter their password..the datetimepicker will automatically store into database..
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click<br />
<br />
Dim Emp_IDDataRow As DataRow<br />
Emp_IDDataRow = Comdataset.EMPLOYEE_DETAIL.FindByEmp_ID(txtID.Text)<br />
<br />
If Emp_IDDataRow IsNot Nothing Then<br />
If txtPass.Text = Emp_IDDataRow!Password.ToString Then<br />
MessageBox.Show("Login Successful!", "infor", MessageBoxButtons.OK, MessageBoxIcon.Information)<br />
With Me<br />
if txtPass.text=true then<br />
.LOGIN_OUTTableAdapter.InsertQueryEmp(.Login_DateDateTimePicker.Value)<br />
.LOGIN_OUTTableAdapter.Fill(.Definition_dbDataSet._LOGIN_OUT)<br />
Else<br />
(part below for logout)<br />
.LOGIN_OUTTableAdapter.InsertQueryEmp(.Login_DateDateTimePicker.Value)<br />
.LOGIN_OUTTableAdapter.Fill(.Definition_dbDataSet._LOGIN_OUT) <br />
End If<br />
End With<br />
Form2.Show()<br />
Else<br />
MessageBox.Show("Invalid Password!", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)<br />
End If<br />
Else<br />
MessageBox.Show("Invalid ID", "ERROR", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)<br />
End If
this maybe can show more..thanks
error given me was
Error 2 Argument not specified for parameter 'Emp_ID' of
'Public Overridable Overloads Function InsertQueryEmp(Log_No As String, Emp_ID As String)
modified on Wednesday, April 9, 2008 10:52 PM
|
|
|
|
|
Member 4442916 wrote: Error 2 Argument not specified for parameter 'Emp_ID' of
'Public Overridable Overloads Function InsertQueryEmp(Log_No As String, Emp_ID As String)
you can't work this out ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
 ya...can't work i also donot know to do correct it
my sql
INSERT INTO `LOGIN/OUT` (`Log_No`, `LogIn_time`, `Login_Date`, `Emp_ID`) VALUES (?, dd-MM-yyyy, HH:mm:ss, ?) i'm not sure wheater correct...
and i change my code like this below..but stil can't work
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click<br />
Dim Emp_IDDataRow As DataRow<br />
Comdataset = Com.getCOMDataset<br />
<br />
Emp_IDDataRow = Comdataset.EMPLOYEE_DETAIL.FindByEmp_ID(txtID.Text)<br />
With Me<br />
If Emp_IDDataRow IsNot Nothing Then<br />
If txtPass.Text = Emp_IDDataRow!Password.ToString Then<br />
MessageBox.Show("Login Successful!", "infor", MessageBoxButtons.OK, MessageBoxIcon.Information)<br />
.LOGIN_OUTTableAdapter.InsertQueryEmp("ddmmyy,hhmmss", .Login_DateDateTimePicker.Value)<br />
.LOGIN_OUTTableAdapter.Fill(.Definition_dbDataSet._LOGIN_OUT)<br />
Else<br />
.LOGIN_OUTTableAdapter.InsertQueryEmp("ddmmyy,hhmmss", .Login_DateDateTimePicker.Value)<br />
.LOGIN_OUTTableAdapter.Fill(.Definition_dbDataSet._LOGIN_OUT)<br />
Form2.Show()<br />
End If<br />
ElseIf Emp_IDDataRow IsNot Nothing Then<br />
MessageBox.Show("Invalid Password!", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)<br />
ElseIf Emp_IDDataRow IsNot Nothing Then<br />
MessageBox.Show("Invalid ID", "ERROR", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)<br />
End If<br />
End With
error given was Syntax error (missing operator) in query expression 'HH:mm:ss'.
can anyone help me out..thanks in advanced
|
|
|
|
|
"'Public Overridable Overloads Function InsertQueryEmp(Log_No As String, Emp_ID As String) "
There is no room for a date/time to be passed in here. You insert a log no and an emp id. You seem to me to be inserting neither. You seem, in fact, to be trying to make this up as you go.
Member 4442916 wrote: INSERT INTO `LOGIN/OUT` (`Log_No`, `LogIn_time`, `Login_Date`, `Emp_ID`) VALUES (?, dd-MM-yyyy, HH:mm:ss, ?) i'm not sure wheater correct...
This is just a disaster. I am assuming the ? is for a parameterised query, but the dd-MM-yyyy stuff is very, very wrong. Where do you expect those values to come from ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
my question is once i enter ID and pasdate and time will automatically store into database
then how to i suppose to change that once i enter my password and ID the time and date will store in database on the spot...can help correct for me..thanks
which mean i only need
INSERT INTO `LOGIN/OUT` (`LogIn_time`, `Login_Date`) VALUES (ddmmyyyy, HHmmss) can i do like that..
|
|
|
|
|
What sort of database is this ? SQL Server has methods you can call to store the current time and date. ddmmyyy is not it, I am sure.
You are storing the time/date of login, but not who logged in ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|