|
Jai Bihar wrote: can you also provide some code to me
To do what?
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
for selecting ouput printer and writing and reading details from registry
|
|
|
|
|
Use the PrintDialog control from the ToolBox to select your printer.
I have posted an example of reading the registry here[^]. You should be able to work out how to write the selected printer to the registry, if you look at the Microsoft.Win32.Registry namespace and the ReadEntry Function in the link provided.
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
Hi to all,
my problem is hopefully not too stupid, but we do not get the following situation solved:
There are several assemblies :
A, B, C and D
B has references to C and D.
If I perform NUNIT testing against assembly B everything works fine.
Now I wish to test assembly A which references assembly B.
The assemly compiles without errors or warnings and terminates at a certain point with a
"FileNotFound" - Exception that is fired by the CLI because assembly D is not found.
If you look in \bin\debug or \bin\release assembly D is missing; from that point of view the exception is OK.
What I really do not understand is the fact that the missing assembly is not copied into the local AppPath as the others.
All references point to the .dll in the \bin\release - path and have the "local copy" option activated.
If I add a reference to assembly D in assembly A everything works fine.
I would have expected to find assembly D automatically in the \bin path for assembly A.
Environment:
VS2005, .Net 2.0, VB.Net
Thanks in advance for any help.
Regards
Thomas
modified on Friday, May 23, 2008 7:36 AM
|
|
|
|
|
Can somebody tell me the code how to scan a registry.
|
|
|
|
|
Assuming you're using VB .Net, seeing as you don't actually say, take a look at the Registry classes in the Microsoft.Win32.Registry namespace.
|
|
|
|
|
Hey frnd i want to know that in VB there is no registry inbuilt fn. Rite???
In Vb.net i import namespace imports.win32
tell me dat how to create the object for registry class.
|
|
|
|
|
I'm sorry, I don't understand what you mean. Are you working with Visual Basic .NET or Visual Basic 6 (or earlier)?
|
|
|
|
|
I m working with .Net, I want to know from where to start as i do not have any idea.After creating the object,what is the next step.
|
|
|
|
|
As I'm not aware of what your trying to achieve, overall, I can't really suggest anything except taking a look at the MSDN documentation for the classes and finding something that meets your needs. Google is also your friend if you have a specific aim in mind that someone might have done before. Then, if you've got a specific question, ask again. Like most people here I won't give out code until you've got something to show you've had a go yourself first.
To give a pointer, though, the Registry Object includes members that encapsulate the various parts of the Registry, and you can loop over them like any other Collection.
|
|
|
|
|
The following code demonstrates how to read a registry entry. You should be able to build on it to incorporate Write, Delete etc.
Public Enum Root As Byte<br />
CurrentUser = 1<br />
LocalMachine = 2<br />
CurrentConfig = 3<br />
ClassesRoot = 4<br />
Users = 5<br />
End Enum<br />
<br />
Function ReadEntry(ByVal RegistryRoot As Root, ByVal Location As String, ByVal Name As String) As String<br />
Dim regKey As Microsoft.Win32.RegistryKey<br />
Select Case RegistryRoot<br />
Case Root.CurrentUser<br />
regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(Location)<br />
Case Root.LocalMachine<br />
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(Location)<br />
Case Root.CurrentConfig<br />
regKey = Microsoft.Win32.Registry.CurrentConfig.OpenSubKey(Location)<br />
Case Root.ClassesRoot<br />
regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(Location)<br />
Case Root.Users<br />
regKey = Microsoft.Win32.Registry.Users.OpenSubKey(Location)<br />
Case Else<br />
regKey = Nothing<br />
End Select<br />
If regKey Is Nothing Then<br />
ReadEntry = Nothing<br />
Else<br />
Try<br />
ReadEntry = regKey.GetValue(Name).ToString<br />
regKey.Close()<br />
Catch<br />
Return Nothing<br />
End Try<br />
End If<br />
End Function
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
hi
I got problem while retrieving records from the active directives
using ado.net code .There are nearly 5000 records ,but I am getting only
1000 records for any search .What may be reason ..please help.
This is the code used for retrieving..
<br />
Dim command As New OleDbCommand("<" & strSearchADsPath & ">", Con)<br />
Dim adap As New OleDbDataAdapter(Command)<br />
Dim cb As New OleDbCommandBuilder(adap)<br />
Dim ds As New DataSet<br />
adap.Fill(ds, "tabUser") <br />
Thanks
Chaitanya
|
|
|
|
|
Hey Chaitanya,
I think you will find the answer on this page[^].
Looks like the trick is along the lines of specifying a value for command.Properties("Page Size") .
Hope this helps.
|
|
|
|
|
Yeah you are when using VB6 but I want to get it in VB.NET
|
|
|
|
|
I have a database field (SQL Server) which is stored as RTF
(e.g.)
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}} \viewkind4\uc1\pard\f0\fs17 This is the text string.\par }
The user has to be able to search on this field, but at the moment the WHERE clause in the SQL
(e.g.)
WHERE Field1 LIKE '%view%'
would return the above record.
Is there anyway to search the RTF field, but only match what in in the displayed text???
Thanks,
the_smiths.
|
|
|
|
|
I doubt it very much. I expect you need to add a plain text column to your DB
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 )
|
|
|
|
|
Ask your question in the SQL Server forum. I believe you may be able to incorporate a Regular Expression in a Stored Procedure or View to remove the RTF formatting from the result of the text column containing the RTF code.
You could then search on the raw text.
I may be leading you up a blind alley, in which case I appologise, but I am fairly sure it can be done.
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
If the data already exists in a remote SQL database to which you can only connect via a 300-baud modem link, then it may be useful to have a script that can convert the RTF-formatted document into text-only. Otherwise, my strong suspicion would be that while you could search for non-RTF text within the RTF document using a sufficiently-intricately-constructed query, the performance would be so much worse than searching in a text-only field that the approach should be considered infeasible for anything but the smallest databases.
Searching for text within the RTF field would require that the server convert every record's RTF data into text format every time a search was run. The server's inherent caching facilities wouldn't be able to help much. The only way to usefully cache the converted texts would be to create a new table to hold them; if you're going to do that, you may as well hold them in the original table.
Returning to vb:
-1- What is the best way to extract the text from RTF?
-2- Is there any good way to put a huge amount of formatted text into a RichTextBox, or is that control simply unsuitable for dealing with monstrous (multi-megabyte) files? Using a StringBuilder to make an RTF string was reasonably fast, but importing a large RTF into a RichTextBox can take a really long time--there seems to be something that's O(n^3) or worse that kicks in with big files.
|
|
|
|
|
This belongs in the SQL Server forum.
However, one solution (assuming you have full control over the database server) is to use the free-text search functionality available in SQL Server (even in MSDE with the add-on feature pack available nowadays).
You need to download and install an IFilter driver for RTF - there is one available from Microsoft (search for "ifilter" and "rtf").
You also have to:
a) make the field binary (image) and add a "file type" field containing the string ".RTF" on all rows that contain rtf data.
b) enable free-text indexing on the database and the table (specifying the relevant fields).
c) use free-text search predicates instead of "LIKE" (such as FREETEXT, CONTAINS...).
As an added bonus, you can install IFilters for other file formats, such as PDF (available from Adobe).
Look here[^] for information and examples.
Peter the small turnip
(1) It Has To Work. --RFC 1925[^]
|
|
|
|
|
For: VB .net Express 2005 or 2008.
If have been searching the Internet and various forums for weeks now trying to figure out how to integrate live video in an application I am writing. Nothing I have read or tried seems to fit with what I am trying to do so I am going to explain my application here and hope someone may have an idea.
Application: Automated dart tournament control software to runs dart tournaments for some local taverns I work with. The software will manage all aspects of the tournament and then display on an external television the brackets and which teams are on which boards and other tournament related information. But I want this to be displayed like how espn displays some of its programs. I want a live feed from our cable box displayed in the upper right %65 of the television. I want general information scrolled on the bottom and current tournament status on the remaining left section.
I am using a video to USB adapter on the computer, which works fine in other applications and I have been able to bring it into VB Express 2008 applications with some demo code I have found. But the display in the VB application demo code is subtly choppy and in black and white. I know there has to be a better way to display live video. I just need to display, not capture or record.
Any suggestions would be wonderful. Also, I am generally new to VB coding and getting pointed toward some sample code I could study and learn from would be great. Or even better, a video control I can just drop in.
Thanks,
Ryan Schuster
|
|
|
|
|
Perhaps the input device is set to PAL in your code and is NTSC, or vice versa ?
Absenm wrote: Or even better, a video control I can just drop in.
If you mean a paid one, tvideograbber works great. If you mean a free one, perhaps search the articles on the site.
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 )
|
|
|
|
|
I will locate the test code I used and see PAL/NTSC. I'll recheck the articles to try to find a free video control but I didn't really see anything in my prior research. I urge others to continue to respond to this thread if you have any ideas (maybe code samples). Thanks.
Ryan
|
|
|
|
|
I have done a lot of video work, and the video feed does get a little shaky and b/w if that setting is wrong. It could be someting else, of course, but I'd look there first.
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 )
|
|
|
|
|
Well, I really do appreshiate your help on this. My understanding of graphics and especially videa is very limited in VB .net (truth is it is limited in general in most aspects). Below is the sample code I have been studying but I can't see where I would look to change any PAL / NTSC settings. I have seen this code (or very simular) distributed in several places so I figured it would be good to learn from. I also just try a sample app that uses DirectShowLib and I am running into the same BW / choppy situation. My device is a Video to USB adaptor model VA11A made by X10. That is pretty much all I know of the device itself. It works fine in other apps like Windows Movie Maker (which ironically usually gives me the most problems).
Thank for any further advice. In the meantime I will continue to search the net for ideas.
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
Const WM_CAP As Short = &H400S
Const WM_CAP_DRIVER_CONNECT As Integer = WM_CAP + 10
Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_CAP + 11
Const WM_CAP_EDIT_COPY As Integer = WM_CAP + 30
Const WM_CAP_SET_PREVIEW As Integer = WM_CAP + 50
Const WM_CAP_SET_PREVIEWRATE As Integer = WM_CAP + 52
Const WM_CAP_SET_SCALE As Integer = WM_CAP + 53
Const WS_CHILD As Integer = &H40000000
Const WS_VISIBLE As Integer = &H10000000
Const SWP_NOMOVE As Short = &H2S
Const SWP_NOSIZE As Short = 1
Const SWP_NOZORDER As Short = &H4S
Const HWND_BOTTOM As Short = 1
Dim iDevice As Integer = 0 ' Current device ID
Dim hHwnd As Integer ' Handle to preview window
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, _
<MarshalAs(UnmanagedType.AsAny)> ByVal lParam As Object) As Integer
Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Integer, _
ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, _
ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
Declare Function DestroyWindow Lib "user32" (ByVal hndw As Integer) As Boolean
Declare Function capCreateCaptureWindowA Lib "avicap32.dll" _
(ByVal lpszWindowName As String, ByVal dwStyle As Integer, _
ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, _
ByVal nHeight As Short, ByVal hWndParent As Integer, _
ByVal nID As Integer) As Integer
Declare Function capGetDriverDescriptionA Lib "avicap32.dll" (ByVal wDriver As Short, _
ByVal lpszName As String, ByVal cbName As Integer, ByVal lpszVer As String, _
ByVal cbVer As Integer) As Boolean
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LoadDeviceList()
If lstDevices.Items.Count > 0 Then
btnStart.Enabled = True
lstDevices.SelectedIndex = 0
btnStart.Enabled = True
Else
lstDevices.Items.Add("No Capture Device")
btnStart.Enabled = False
End If
btnStop.Enabled = False
btnSave.Enabled = False
picCapture.SizeMode = PictureBoxSizeMode.StretchImage
End Sub
Private Sub LoadDeviceList()
Dim strName As String = Space(100)
Dim strVer As String = Space(100)
Dim bReturn As Boolean
Dim x As Integer = 0
'
' Load name of all avialable devices into the lstDevices
'
Do
'
' Get Driver name and version
'
bReturn = capGetDriverDescriptionA(x, strName, 100, strVer, 100)
'
' If there was a device add device name to the list
'
If bReturn Then lstDevices.Items.Add(strName.Trim)
x += 1
Loop Until bReturn = False
End Sub
Private Sub OpenPreviewWindow()
Dim iHeight As Integer = picCapture.Height
Dim iWidth As Integer = picCapture.Width
'
' Open Preview window in picturebox
'
hHwnd = capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 640, _
480, picCapture.Handle.ToInt32, 0)
'
' Connect to device
'
If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) Then
'
'Set the preview scale
'
SendMessage(hHwnd, WM_CAP_SET_SCALE, True, 0)
'
'Set the preview rate in milliseconds
'
SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0)
'
'Start previewing the image from the camera
'
SendMessage(hHwnd, WM_CAP_SET_PREVIEW, True, 0)
'
' Resize window to fit in picturebox
'
SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, picCapture.Width, picCapture.Height, _
SWP_NOMOVE Or SWP_NOZORDER)
btnSave.Enabled = True
btnStop.Enabled = True
btnStart.Enabled = False
Else
'
' Error connecting to device close window
'
DestroyWindow(hHwnd)
btnSave.Enabled = False
End If
End Sub
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
iDevice = lstDevices.SelectedIndex
OpenPreviewWindow()
End Sub
Private Sub ClosePreviewWindow()
'
' Disconnect from device
'
SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, iDevice, 0)
'
' close window
'
DestroyWindow(hHwnd)
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
ClosePreviewWindow()
btnSave.Enabled = False
btnStart.Enabled = True
btnStop.Enabled = False
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim data As IDataObject
Dim bmap As Image
'
' Copy image to clipboard
'
SendMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0)
'
' Get image from clipboard and convert it to a bitmap
'
data = Clipboard.GetDataObject()
If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
bmap = CType(data.GetData(GetType(System.Drawing.Bitmap)), Image)
picCapture.Image = bmap
ClosePreviewWindow()
btnSave.Enabled = False
btnStop.Enabled = False
btnStart.Enabled = True
If sfdImage.ShowDialog = DialogResult.OK Then
bmap.Save(sfdImage.FileName, Imaging.ImageFormat.Bmp)
End If
End If
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If btnStop.Enabled Then
ClosePreviewWindow()
End If
End Sub
End Class
|
|
|
|
|
Hello
I have posted this problem few weeks back but still it's not been done so i am posting this again
i have create one small application in sql to save image and delete saved image from database it's works fine i can add new images to database and then i can also delete saved images from database but problem is when i add or delete image to database it dosent shows changes on screen i mean if there is 2 images in database and if i delete one image from database it deletes the image and it should shows that there is one image in database but it still shows 2 images in database but if i close the application and re start it then it shows one image in database i am totaly confuse please help me with this issue
i am pasting code for conn, add image and delete image
Private Function GetDBConnection()
' Compose the database file name.
' Modify this if the database is somewhere else.
Dim DBname As String = Application.StartupPath()
DBname = DBname.Substring(0, DBname.LastIndexOf("\bin"))
DBname = DBname & "\Images.mdf"
' Compose the connect string.
Dim connect_string As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=" & _
DBname & ";Integrated Security=True;User Instance=True"
' Open a database connection.
Dim SqlConn As New Data.SqlClient.SqlConnection(connect_string)
SqlConn.Open()
' Return the connection.
Return SqlConn
End Function
Private Sub LoadImages()
dsImage.Clear()
Try
conImage = GetDBConnection()
daImage.Fill(dsImage, "Images")
Catch ex As Exception
MsgBox(ex.Message)
End Try
conImage.Close()
conImage.Dispose()
Call PoChng()
End Sub
Private Sub PoChng()
If Me.ImagesBindingSource.Count = 0 Then
Label1.Text = "Empty Database"
Else
Label1.Text = (Me.ImagesBindingSource.Position + 1).ToString & " Of " & _
(Me.ImagesBindingSource.Count).ToString
End If
End Sub
Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
picImage.Image = Nothing
txtImageFile.Text = ""
txtTitle.Text = ""
OpenFileDialog1.ShowDialog()
Dim sFilePath As String
sFilePath = OpenFileDialog1.FileName
If sFilePath = "" Then Exit Sub
If System.IO.File.Exists(sFilePath) = False Then
Exit Sub
Else
txtImageFile.Text = sFilePath
mImageFilePath = sFilePath
End If
End Sub
Private Sub GetImage()
Dim fs As FileStream = New FileStream(mImageFilePath.ToString(), FileMode.Open)
Dim img As Byte() = New Byte(fs.Length) {}
fs.Read(img, 0, fs.Length)
fs.Close()
mImageFile = Image.FromFile(mImageFilePath.ToString())
Dim imgHeight As Integer = mImageFile.Height
Dim imgWidth As Integer = mImageFile.Width
Dim imgLength As Integer = mImageFile.PropertyItems.Length
Dim imgType As String = Path.GetExtension(mImageFilePath)
mImageFile = Nothing
' image content
Dim pic As SqlParameter = New SqlParameter("@pic", SqlDbType.Image)
pic.Value = img
commImage.Parameters.Add(pic)
' title
Dim title As SqlParameter = New SqlParameter("@title", System.Data.SqlDbType.VarChar, 50)
title.Value = txtTitle.Text.ToString()
commImage.Parameters.Add(title)
' type
Dim itype As SqlParameter = New SqlParameter("@itype", System.Data.SqlDbType.Char, 4)
itype.Value = imgType.ToString()
commImage.Parameters.Add(itype)
' height
Dim iheight As SqlParameter = New SqlParameter("@iheight", System.Data.SqlDbType.Int)
iheight.Value = imgHeight
commImage.Parameters.Add(iheight)
' width
Dim iwidth As SqlParameter = New SqlParameter("@iwidth", System.Data.SqlDbType.Int)
iwidth.Value = imgWidth
commImage.Parameters.Add(iwidth)
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
'get sql connection
Try
conImage = GetDBConnection()
Dim sSQL As String = "INSERT INTO Images (Pic,Title, IType, Height, Width) VALUES(" & _
"@pic, @title, @itype, @iheight, @iwidth)"
commImage = New Data.SqlClient.SqlCommand(sSQL, conImage)
Call GetImage()
commImage.ExecuteNonQuery()
MessageBox.Show("Image successfuly saved in database", "Image Load")
Catch ex As Exception
MsgBox(ex.Message)
End Try
commImage.Dispose()
commImage = Nothing
conImage.Close()
conImage.Dispose()
Call LoadImages()
End Sub
please help
waiting for your kind rep.
have a nice day
thank you
|
|
|
|
|