|
I know Shell function, but what is SHFileOperation? How do I use it to copy my font file?
chatura
|
|
|
|
|
The Win32 API Shell functions...SHFileOperation tells the Windows Shell to do the file copy, just like if you were to drag and drop a file in Explorer.
SHFileOperation[^] on PInvoke.net
SHFileOperation[^] on MSDN
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have been searching the internet and reviewing books for a while now trying to determine how exactly to read/write directly to the disk in NTFS using Visual Basic. I have had little success and I am hoping that someone here can help me.
I believe that it comes down to API calls using readfile, etc. to get a handle to the drive and process the information, but I'm at a loss as to how to actually program this.
I've seen a good example in C++ here from T.YogaRamanan but I have not worked in that language for several years and can not break down the logic.
My goal is to write a program that will display the contents of a drive (including deleted files) based on the Master File Table.
Any help would be appreciated but what I am hoping for is someone to clearly identify the steps involved: Step one do this, Step two do that, etc.
Sample Code would be a definite bonus.
Thank You
|
|
|
|
|
Wow, haven't seen this one in a while...
The .NET BCL doesn't have anything that would help you do this. You'll have to P/Invoke all the Win32 API functions to do this. You need CreateFile[^] to open the disk and get a handle. The .NET BCL File functions won't work with disk/volume handles and won't open those either. Once you have the handle, you can only use the Win32 API file functions to read/write the disk.
There's no examples of doing this in VB.NET that I know of. Most of what you'll find is in C++.
The hard part of this is setting up all the calls to CreateFile, ReadFile, WriteFile, and CloseHandle. You'll also need to declare the structures and enums you'll need to call these functions. But, once that's done, it's a matter of calling CreateFile to open the drive, the using ReadFile and WriteFile, to read/write the disk sectors, then CloseHandle to release the disk.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the reply.
Sorry for the confusion, when I referred to Visual Basic, I meant Visual Basic 6, not VB.NET. I never use .net for anything, not yet anyway.
I know it is possible as I've seen demos done in VB but have no accompanying source code.
I have the general idea of what steps are involved but I can not seem to get it working. MSDN only lists the api names but does not provide an example in how to actually use them to achieve anything (except for c++ or c# code).
If anyone has a code sample in Visual Basic 6 of setting up whatever structures, enums and calling the necessary functions, I would appreciate it.
Again, to be clear, I am using Visual Basic 6 on Windows XP with a NTFS formatted drive (obviously) and I am trying to generate a list of all files and folders on the drive (including deleted ones). My main objective here is to access the Master File Table and list all of it's records.
Thanks,
Dan
|
|
|
|
|
IH8Microsoft wrote: I know it is possible as I've seen demos done in VB but have no accompanying source code.
It is possible. I just have never seen any example code for it.
IH8Microsoft wrote: I am trying to generate a list of all files and folders on the drive (including deleted ones). My main objective here is to access the Master File Table and list all of it's records.
This is going to force you to do FAR more than just read disk sectors. Now you're getting into parsing the NTFS structures. You'll want to see if you can find the book "NT File System Internals" (which is out of print BTW). It's the best source of information ever written on NTFS.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'll keep my eyes open for that book, maybe it is still available somewhere.
I have some documentation that well describes the NTFS structure, the records, headers, attributes, etc. but once again, it is the technical syntax and logic in Visual Basic that I am having trouble with. I know that once I get the first few lines working, the rest will follow.
I guess I was just hoping that some had done something like this before and had the first few lines to get me started.
I any case, I'm going to keep working on it as it has now become a personal mission
Thank you for your time, I appreciate it.
|
|
|
|
|
Hello!
I have been trying to resize an image (which is loaded to Picturebox1). The actual image size is greater than the size of Picturebox1. The picturebox1 uses strechimage attribute. My aim is to adjust the loaded image size and write it as a watermark on to another image. It writes but it doesn't resize the image according to size of the picturebox1 Width & Height. It is using the original size of the image when it writes.
If you have an idea why that happens, please let me know!
Thanks!
CODE::
Private Function DrawImageCallback(ByVal callBackData As IntPtr) As Boolean
'Test for call that passes callBackData parameter.
If callBackData.Equals(IntPtr.Zero) Then
' If no callBackData passed, abort DrawImage method.
Return True
Else
' If callBackData passed, continue DrawImage method.
Return False
End If
End Function
' Copy the watermark image over the result image.
Private Sub DrawWatermark(ByVal watermark_bm As Bitmap, _
ByVal result_bm As Bitmap, ByVal x As Integer, ByVal y As Integer)
Dim imageCallback As New Graphics.DrawImageAbort(AddressOf DrawImageCallback)
Dim imageCallbackData As New IntPtr(1)
' Create rectangle for adjusted image.
Dim destRect2 As New Rectangle(PictureBox1.Location.X, PictureBox1.Location.Y, PictureBox1.Width, PictureBox1.Height)
Dim es As Graphics = Graphics.FromImage(result_bm)
es.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
' Create image attributes and set large gamma.
Dim imageAttr As New ImageAttributes()
'imageAttr.SetGamma(4.0F)
' Draw adjusted image to screen.
es.DrawImage(watermark_bm, destRect2, x, y, PictureBox1.Width, PictureBox1.Height, GraphicsUnit.Pixel, imageAttr, imageCallback, imageCallbackData)
End Sub
|
|
|
|
|
Of course it doesn't resize the image. You are taking a portion of the watermark image the same size as the picturebox and draw that onto an area that is the same size as the picturebox.
---
b { font-weight: normal; }
|
|
|
|
|
Yes! you are right about it however I am dealing with a streched image. The actualy size of the image is greater than the Picturebox width and height. It is the problem. I want to draw the large image withing the with and height of Picturebox width and height. When I try to do that, it is getting the portion of the image.
Probably, I am making a mistake if you know the point, please drop me a few lines of sample code...
Appreciated! Thanks
|
|
|
|
|
Read my previos post again, and take a look at the parameters you use when drawing the image. You will se that you are taking only a part of the watermark image, just as I said.
If you want to draw the entire image, you have to specify the size of the entire image, not a portion of the image the size of the picture box.
---
b { font-weight: normal; }
|
|
|
|
|
Yes! you were right! It is working now!
Thanks a lot!
|
|
|
|
|
Hello
I am learning VB.NET and was toying with the idea of embellishing my database program with Crystal Reports to provide some data reporting facilities.
I was put off by the cost of Crystal, however, and was wondering if there were any free or very low cost report writers that would work with VB.NET. I want to run the reports from within VB, extracting the data either from Access or SQL Server.
If anyone knows of any such report writers, I would be very grateful to hear from them.
Many thanks,
Trimtrom
|
|
|
|
|
Hi. I am writing a data web service in VS 2005 using Ms Sql Server 2005 as data server. I wrote a connection strin gin the web.config file in the area. I used it in the code, but when I invoke it, it doesnt bring up the details. I know there is some data in the table, but it doesnt bring it up via the web service call.
what would I be doing wrong?
|
|
|
|
|
Hi all,
Please help !
Can I pass array parameters to SQL stored Procedure?
Example...
I hava stored procedure like follow
'*********************************************
@Ids varchar(128)
SELECT [LastName] FROM Employees WHERE EmployeeID IN (@Ids)
'*********************************************
When I pass (@Ids = "'1','2','3'") It didn't work.
I don't want directly use commandText.
What should I do?
!Thanks!
!alien!
|
|
|
|
|
No, you can't pass an array to a stored procedure.
You could create a table variable and put the values into that. There is no command to split the string, though, so you would have to do it with string manipulation.
Here's an example of using a table variable, though:
<br />
set nocount on<br />
declare @t table (id varchar(10))<br />
insert into @t values('1')<br />
insert into @t values('2')<br />
insert into @t values('3')<br />
select [LastName] from Employees where EmployeeID in (@t)
Or perhaps the last line has to be:
select [LastName] from Employees where EmployeeID in (select id from @t)
---
b { font-weight: normal; }
-- modified at 5:36 Saturday 4th February, 2006
|
|
|
|
|
Hello!
My aim is to access to scanner and scann the photos or documents via vb.net. Is there any sample code about how to do that in vb.net?
Thanks!
|
|
|
|
|
am porting a vb library to vb.net. The vb library has an external
call to an unmanaged dll.
Existing code:
//External function declaration
Private Declare Function Uncompress& Lib "COMPR.DLL" (ByVal SrcSt$,
ByVal SrcLen&, Dest As Any, ByVal DestLen&)
//Invocation of external function
lReturn = Uncompress(sCompressedResult, Len(sCompressedResult),
aResults(ARRAY_START), ByVal lNewLength)
[where aResults is a double array. The COMPR.Uncompress function
basically uncompress a string 'sCompressedResult' and fills the array
aResults. The array is initialized before calling the external
function]
My understanding is that( Please correct me if I am wrong):
a. The third parameter in declaration 'Dest as Any' means a parameter
of variant type.
b. At invocation, the first element of the double array is passed.
i.e., a pointer to the first element in the double array is passed to
the external function.
c. The Uncompress function expands the compressed data, fills/replaces
the double array with values.
d. The changed values are available to the caller after the Uncompress
function has returned.
Now, I have to call the COMPR.Uncompress method from Vb.Net.
>From browsing the net, I got a lot of information regarding this(
Please correct me if I am wrong):
a. We have to mark the parameter as InAttribute(), Out().
b. We should pin the object so that GC does not change address.
c. We should pass a pointer TO THE FIRST OBJECT OF THE ARRAY to the
native function.
d. Array of type double is non-blittable and so we have to do the
marshaling.
This is the code I wrote:
//External method declaration
<dllimport("compr.dll", entrypoint:="UnCompress" ,=""
setlasterror:="True," charset:="CharSet.Auto," exactspelling:="True,"
callingconvention:="CallingConvention.StdCall)"> _
Public Shared Function UnCompress(ByVal compressedResult As String,
ByVal length As Long, <inattribute(), out(),=""
marshalas(unmanagedtype.struct)=""> ByRef destinationArrayElement As
Object, ByVal newLength As Long) As Long
End Function
//Invocation
'Pin the object
Dim resultsHandle As GCHandle
resultsHandle = GCHandle.Alloc(aResults(ARRAY_START),
GCHandleType.Pinned)
Dim resultsPointer As IntPtr = resultsHandle.AddrOfPinnedObject()
'Invoke
returnValue = UnCompress(sCompressedResult, Len(sCompressedResult),
resultsPointer, newLength)
My problem is that I get the return value correctly, but the array does
not get changed....I get the same data that is passed to the external
function. I think the changes made by the native function is not
persisting.
There is no problem with any of the parameters - I have checked the
same parameters using the existing vb dll and it works. I would like to
know why I dont get the modified array even though I am passing a
pointer to the first element of the array and am pinning the element.
Is this the correct way to marshal (UnmanagedType.struct) and is this
the correct way to pin object?
Any help would be appreciated,
Jim
Jim
|
|
|
|
|
hi every one,
i have values in external array.
Like
str(0)="1234"
str(1)="3 94 34"
i want to send this values into the databse.
all fields in the database are Varchar of size (30).
when i am sending values into the database
like..
insert into tblone(no,no1)values('"& str(0) & "','"& str(1) &"')
i am not getting any problem.
but when i do like this
insert into tblone(no,no1)values("& str(0) & ","& str(1) &")
(removed single quotes) i am getting syntax error.
can any body help me...
raj
|
|
|
|
|
Values for Varchar(),Date etc Fields must be enclosed in Single Quote and for Numeric Field with out Single Quote. It is syntax nothing more.
Regards,
Javed
|
|
|
|
|
As Javed alluded to, inserting string data into a db requires Double Quotes.
-- modified at 4:13 Saturday 4th February, 2006
|
|
|
|
|
Ok I've looked all over the place here and on other forums and surpprizingly I can't find this anywhere.
How do I get the IP Address my browser is at right now and display it in my addressbar (a.k.a TextBox1)?
Thanx for any help you can give me.
|
|
|
|
|
There are two answers to this depending on what you are really looking for:
First, the really ipaddress can be obtained from the DNS object in the framework. you textbox assignment would look something like: text1.value = system.Net.Dns.GetHostByAddress.tostring()
However, if you are doing asp.net, you may really desire what the url adress bar "server" name is for example:
http://www.codeproject.com/script/comments/user_reply.asp
the server name is "www.codeproject.com" which can be applied to a textbox like so: text1.value = page.Request.ServerVariables ("SERVER_NAME")
Hope that helped.
do you need to investigate an online backup[^] company
|
|
|
|
|
Hi Jason,
Yes what I'm looking for is to display the full http:// address that one sees in the browser address bar. I'm creating a very simple web browser and the address bar (Textbox) works fine but when I click on a page link to another link I would like to display the address in the same address bar. Will your second example work for this? And is there more to the code to do this then just putting your example to the textbox I have?
-- modified at 1:35 Saturday 4th February, 2006
|
|
|
|
|
... The second example will only work if you are working in Asp.net (thus providing a webpage to a client through a browser) as you are creating a "simple web browser" I am sure that the second concept will not function like you want.
When the user of your application clicks on a link within the document that you are presenting to them, why not just copy that link to your addressbar_textbox.value?
do you need to investigate an online backup[^] company
|
|
|
|
|