|
You can't do that. If you give a user permission to open that file, they can open it using anything, including Notepad or some file byte editor. You're only solution, like Christian said, is to encrypt the file so it can't be understood by anything other that your application.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Is it possible to connect or print file in a thermal printer using VB .net?
if it is possible, How to connect or print file/documents in a thermal printer. this printer is a network printer. I've been searching a quit long time but i did not find any article that is related to my problem.
Thanks!
|
|
|
|
|
A printer is a printer, your driver handles communucation to it, no matter how it prints. Any printing tutorial should work, you just need to install it as a network printer on the PC running your program.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I am looking into programming a system information tool as part of a application suite, which I am currently having problems with. At the moment, I have been reading up on the aspects of the WMI at the MSDN section over at Microsoft.
I am wondering if anyone has any example code on making a query as the System.Management doesn't seem to be able to be referenced from the project properties screen and cant't use the Imports System.Management bit of code to include it.
Any help would be greatly appreciated.
Thanks, Andrew Robinson.
|
|
|
|
|
First you need to reference System.Management.dll
Here is some code for retrieving NT Users and NT Groups
Imports System.Management 'Need to reference System.Management.dll<br />
<br />
<br />
Public Module NTDomain<br />
<br />
Public Function GetNTUsers(ByVal NTDomain As String) As DataTable 'This function uses System.Management namespace<br />
Dim dtNTUsers As New DataTable<br />
With dtNTUsers<br />
.Columns.Add(New DataColumn("FullName"))<br />
.Columns.Add(New DataColumn("Name"))<br />
.Columns.Add(New DataColumn("Domain"))<br />
.Columns.Add(New DataColumn("LocalAccount"))<br />
<br />
Try<br />
Dim searcher As New ManagementObjectSearcher( _<br />
"\\" & NTDomain & "\root\CIMV2", _<br />
"SELECT * FROM Win32_UserAccount")<br />
<br />
Dim en As System.Management.ManagementObjectCollection.ManagementObjectEnumerator = searcher.Get.GetEnumerator<br />
While en.MoveNext<br />
Dim queryObj As ManagementObject = en.Current<br />
Dim dr As DataRow<br />
dr = .NewRow<br />
dr("FullName") = queryObj("FullName")<br />
dr("Name") = queryObj("Name")<br />
dr("Domain") = queryObj("Domain")<br />
dr("LocalAccount") = queryObj("LocalAccount")<br />
.Rows.Add(dr)<br />
End While<br />
.AcceptChanges()<br />
Catch ex As System.Exception<br />
Throw New PDM.DBA.GetNTUserListException<br />
Finally<br />
Dim drUser As DataRow<br />
drUser = .NewRow<br />
End Try<br />
Return dtNTUsers<br />
End With<br />
End Function<br />
<br />
Public Function GetNTGroups(ByVal NTDomain As String) As DataTable 'This function uses System.Management namespace<br />
<br />
Dim searcher As New ManagementObjectSearcher( _<br />
"\\" & NTDomain & "\root\CIMV2", _<br />
"SELECT * FROM Win32_AccountSID")<br />
<br />
Dim dtNTGroups As New DataTable<br />
With dtNTGroups<br />
.Columns.Add(New DataColumn("Type"))<br />
.Columns.Add(New DataColumn("Name"))<br />
Dim en As System.Management.ManagementObjectCollection.ManagementObjectEnumerator = searcher.Get.GetEnumerator()<br />
While en.MoveNext<br />
Dim queryObj As ManagementObject = en.Current<br />
Dim sSplit() As String = Split(queryObj("Element"), ",")<br />
Dim sType As String<br />
<br />
If sSplit(0).Contains("Win32_Group") Then<br />
sType = "Group"<br />
ElseIf sSplit(0).Contains("Win32_SystemAccount") Then<br />
sType = "System Account"<br />
ElseIf sSplit(0).Contains("Win32_UserAccount") Then<br />
sType = "User"<br />
Else<br />
sType = "Unknown"<br />
End If<br />
<br />
sSplit(1) = Replace(sSplit(1), "Name=", "")<br />
sSplit(1) = Replace(sSplit(1), """", "")<br />
<br />
Dim dr As DataRow<br />
dr = .NewRow<br />
dr("Type") = sType<br />
dr("Name") = queryObj("Element")<br />
.Rows.Add(dr)<br />
End While<br />
.AcceptChanges()<br />
End With<br />
Return dtNTGroups<br />
End Function<br />
<br />
End Module
Hope this helps, took me a while to sort this out as well.
Regards
Steve Jowett
|
|
|
|
|
could someone please help me with searching for items displayed in a listview. i want to be able to search by surname or name. that once i search, the listview automatically collapses to show the name that corresponds to the search typed in the search textbox.
-- modified at 18:41 Tuesday 22nd August, 2006
|
|
|
|
|
You need to iterate over your items and search them.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I have a form that is set to have an icon appear in the upper left hand corner of the title bar. I made the icon in Visual Studio 2005. It looks just fine on my machine (which runs windows 2000) but I've tried it on an XP machine and it has that default icon picture....I am guessing that I need to make another Icon Type in my icon to get it to work, but I don't know what type XP requires. Does anyone know if this is in fact my problem, and/or what type of icon I need to create? I am currently using a 16 by 16 with 16 bit color.
|
|
|
|
|
i wanted to clarify something
whats teh difference between public,private and static variables?
my idea is that static variables can be changes anywhere in the program and once it has change the change is reflected throughtout the program and i think thats the same for public
but thinking about an example if a variable is defined as static in one function and is pass to another function and value is changed will the value be changed in the previous function.i think so............as for the public i dont think the value change will be reflected in the previous program
kenny
|
|
|
|
|
First of all, if you want to be a programmer, learn to use google.
public - this variable/method is visible to anyone
protected - this variable/method is visible to this class, and classes derived from it
private - this variable/method is visible to this class only
private and protected are used for encapsulation, so a class can hide it's internal details and expose only a public interface.
static is completely unrelated. If a method is static, it has no state, you cannot use this, or any member variables in that method. Factory methods are one example of a method that will be static. A variable that is static means it only exists once. If you have 50 instances of foo, and bar is a static int, if you change it in one instance, that value is set for all instances.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
A static variable is created in the class. That means that it's available even if you don't have any instances of the class. Also if you have ten instances of the class, there is still only one of the static variable.
Variables that are non-static are created in the instance of the class. If you create ten instances, each will have their own set of variables.
Private variables are only reachable from within the same class, while public variables are also reachable from outside the class.
OOP purists never use public variables. Instead they (we) declare them as private, and create a public property to access each variable.
---
b { font-weight: normal; }
|
|
|
|
|
Hi All,
I want to write some program that control windows behavior, like hiding the desktop, disabling Ctrl+Alt+Delete, Hide Start Menu, and all this stuff, how can i make it under .NET
and plz give me a detailed answer coz am new to this field
thanks in advance
|
|
|
|
|
You don't. This is all controlled using Group Policies. Get the Windows XP Resource kit and you'll find all this stuff documented.
BTW, you can't disable Ctrl-Alt-Delete. You CAN, however, disable the stuff in the box that shows up. Again, all controlled through policies.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Well, so can i edit this policies -i mean in the group policy- through programming, i know that i can reach this stuff through MMC and then editing the policies throught the MMC wizards, but can i have my own wizards which do the same???
thanks for ur answer
|
|
|
|
|
You could, but why reinvent the wheel?
The policies are mostly just registry entries and controlling security on those entries. The code to manipulate the registry and security is not that hard. The hard part, and very tedious, is figuring out what registry entries to change and what values to put into them. Again, all documented in the Windows XP Resource Kit.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
if a computer does not have access installed can you still run a vb.net program using a microsoft access database?
dbellman
dbellman@bellmanware.com
|
|
|
|
|
You probably just need the Access driver installed to run it. I think most of the newer Windows operating systems, or at least Windows XP, already have the driver installed.
|
|
|
|
|
Yes. You just have to make sure that the user has a certain version of Microsoft Data Access Components (MDAC) installed. You can do this by setting the MDAC as a prerequisite in the setup project of your program.
|
|
|
|
|
Yes, a VB.Net application can can work with an Access database without a full version of ACCESS installed. The proper Access runtime must be present (installed) -- part of Office Extensions for .Net 200x.
Note that Microsoft has removed the .Net 2003 Office Extensions from its Web sites so you can no longer easily obtain them. It becomes an interesting exercise in missing pages and pages that automatically send you back to themselves in infinite loops!
As long as the proper ODBC, etc. drivers are installed and you are not trying to do anything "fancy", you may not need the Office Extensions.
Hope this helps.
Charles Wolfe
C. Wolfe Software Engineering
|
|
|
|
|
Hello,
I am trying to add files into a listview and take them out of listview and store into windows explorer.
I have no problem in dragging items from the windows explorer into my listview. But I could not manage to drag items from the listview and drop into explorer. All I want to know is, when I drag an item and drop into a windows explorer, I need to know where (into which folder?) the item is dropped.
Can anybody please help?
Thank you
|
|
|
|
|
Ok here it is. I am creating an estimator in VB 2005. The break down is like this Customer-->Jobs-->Estimates-->Rooms-->Items All are one to many relationships.(Works fine in Access)
I have gotten everything working then hit a roadblock(Due to being new to VB). I need to show all the items for a room in a editable list(Subform that VB does not have). An Item has the following fields. Group,Type,Qty,UOM,Price,Upgrade,UpgradePrice,Zoned,ZoneChage,Linetotal
Group is a Combo box that filters the selections of Type
Group A containes Type1,Type2
Group B containes Type3,Type4
etc...
Type is also a Combo box that sets the Price,UOM,Zone,Zonecharge
Qty is just a text box that holds # of items
Upgrade is a combo box that sets the upgrade price based on selection
Linetotal is calculated
Data must be able to be changed on the fly and new calculations performed in realtime(Like Excell(Currently being used for estimator)
I have tried the datagrid and listview both without success(I think they might work with more advanced code)
I even tried putting 25 items in one table but my update dies because i go over the 127 field mark. I have been on this for weeks and I can't find a solution. Any help would be great.
|
|
|
|
|
i work in vb.net 2003 i put data in datagrid ineed when user select row from datagrid and press delete key from keyboard prevent delete this row and message appear
ma_refay
|
|
|
|
|
When I use the function SpecialFolders(Desktop), the path I back is C:\Documents and Settings\All Users\Desktop. Is there a way for me to parse this string and get only the portion "C:\Documents and Settings\All Users\" so that I can concatenate something else to it instead of "Desktop"? Thanks.
|
|
|
|
|
You can always use the Left function to get the first part of the string if you want to be messy.
VB6 Example:
strTemp = SpecialFolders(Desktop)
path = Left(strTemp, Len(strTemp - 7)
VB.NET Example:
strTemp = SpecialFolders(Desktop)
path = strTmp.Substring(0, strTmp.Length - 7)
|
|
|
|
|
You don't need to do that. All you need is the value of the USERPROFILE environment variable:
Set WshShell = WScript.CreateObject("WScript.Shell")
ProfilePath = WshShell.ExpandEnvironmentStrings("%USERPROFILE%")
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|