Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




How To Save & Load An Exe's Icon With The ExtractAssociatedIcon Win32 API Function?


sups all
i need to know How to save & load an exe's icon with the ExtractAssociatedIcon Win32 API function.
can some1 help me?
tnx




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Save Picture AFTER Using ExtractAssociatedIcon. HELP
Option Explicit
Private Declare Function ExtractAssociatedIcon Lib "shell32.dll" Alias "ExtractAssociatedIconA" (ByVal hInst As Long, ByVal lpIconPath As String, lpiIcon As Long) As Long
Private Declare Function DrawIcon Lib "user32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long

Private Sub Command1_Click()
Dim hIcon As Long
hIcon = ExtractAssociatedIcon(0, "Notepad.exe", 0)
If hIcon = 0 Then Exit Sub
Call DrawIcon(Picture1.hDC, 0, 0, hIcon)
End Sub

Private Sub Command2_Click()
SavePicture Picture1.Picture, "C:/pic1.ico"
End Sub

Function To Save/load Data From All Textboxes Into Registry With Save/GetSetting?
anyone have a function to save all values to the registry?

Load/Save Icon
Yo all
i need a code which saving an ico files and opening ico files (into picture or something)
can some1 plz post the code here?

Need Help On Load/save Function..
I need help on this to make load / save function work..

PS: you can download the exampple and work on that,much easier... But please help!!

What i need here is for the save function to save each item from the list in a new line in the "data.ads" , and for the load function
to clear the list and read each line ,correctly into the list again...
Can anyone help me??
Im stuck, cause i don't know enough...



VB Code:
Private Sub Command3_Click()List1.ClearEnd Sub Private Sub Command4_Click()    Dim ls    ls = List1.ListCount - 1    List1.ListIndex = 0   'MsgBox ls    Open App.Path & "Data.ads" For Random As #1        List1.ListIndex = ls        For e = 0 To ls        Put #1, , SplitTab(0) & vbTab & "€€" & vbTab & SplitTab(1)        Next e    Close #1End Sub Function SplitTab(nr)'If List1.ListIndex = -1 Then List1.ListIndex = 0Dim Tabs() As StringTabs = Split(List1.Text, vbTab)SplitTab = Tabs(nr)End Function  Private Sub Form_Load()Dim i 'count valueList1.ClearFor i = 0 To 20List1.AddItem "ehh: " & i & vbTab & "Item: " & iNext iEnd Sub   Private Sub Command1_Click()'sort/search buttonDim fnd As IntegerDim strTemp, strTemp2List1.ListIndex = 0For fnd = 0 To List1.ListCount - 1''MsgBox fnd 'Need To AutoSelect Item In List Here'Start at first item and ending on last itemList1.ListIndex = fnd 'this gives a "invalid property value" Dim SplitTab() As StringSplitTab = Split(List1.Text, vbTab)strTemp = SplitTab(0)strTemp2 = SplitTab(1)''MsgBox strTemp 'Show you what it does 'strTemp = List1.List(fnd)If InStr(1, strTemp, Text1.Text) Then List1.RemoveItem fndList1.AddItem strTemp & vbTab & strTemp2, 0End IfNext fndList1.ListIndex = 0List1.ListIndex = -1  End Sub Private Sub Text1_Change()Text1.Text = ""End Sub

Anyone Have A Function To Load/save A Variable Into A File?
Ive been coding in vb for years.. and i STILL to this day do not get the stupid file system thing... to do something basic like load or save a variable to a file

do you use get? put? input? lof? buffers? loops? output?

ive seen so many ways, they all get mixed together..


anyone have 2 very simple function that will just load a file and save a file to a string?

thanks

Win32 Icon
this is going to sound really dumb.
where can i retrieve the standard win32 commandline icon? I can't disable VB's effort
thanks

Win32 API CreateProcess Function
I am using this function to start other applications from VB program. The application started does not always appear in front of the VB form. Is there anyway of ensuring that any application created this way always appears in front of the VB form.

Win32 API CreateProcess Function
I am using this function to start other applications from VB program. The application started does not always appear in front of the VB form. Is there anyway of ensuring that any application created this way always appears in front of the VB form.

Use Win32 Api Function Search File
hello,

i've found some vba code to use de search file from the windows kernel :

Code:
Option Explicit

'32-bit API declarations

Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long

Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long

Public Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type


Sub ListFiles()

Dim msg As String, answer As String
Dim Directory As String
Dim R As Integer
Dim i As Integer
Dim StartDate As Single


msg = "Select a location containing the files you want to list."
Directory = GetDirectory(msg)
If Directory = "" Then Exit Sub
If Right(Directory, 1) <> "" Then Directory = Directory & ""

' Insert headers

R = ActiveCell.Row
Cells(R, 1) = "FilePath"
Cells(R, 2) = "Size"
Cells(R, 3) = "Date/Time"
Cells(R, 4) = "Filename"
Range("A1:C1").Font.Bold = True
R = R + 1

On Error Resume Next
With Application.FileSearch
.NewSearch
.LookIn = Directory
.Filename = "*.*" ' this can be '*.*
.SearchSubFolders = True
.Execute
For i = 1 To .FoundFiles.Count
If FileDateTime(.FoundFiles(i)) > StartDate Then
Cells(R, 1) = .FoundFiles(i)
Cells(R, 4) = Right(Cells(R, 1), Len(.FoundFiles(i)) - InStrRev(Cells(R, 1).Value, ""))
Cells(R, 2) = FileLen(.FoundFiles(i))
Cells(R, 3) = FileDateTime(.FoundFiles(i))
R = R + 1
End If
Next i
End With
'Columns("A:C").Select
'Selection.Columns.AutoFit

'ActiveSheet.Columns("1:3").AutoFit
MsgBox "file listing complete"

End Sub

Function GetDirectory(Optional msg) As String
Dim bInfo As BROWSEINFO
Dim path As String
Dim R As Long, x As Long, pos As Integer

' Root folder = Desktop
bInfo.pidlRoot = 0&

' Title in the dialog
If IsMissing(msg) Then
bInfo.lpszTitle = "Select a folder"
Else
bInfo.lpszTitle = msg
End If

' Type of directory to return
bInfo.ulFlags = &H1

' Display the dialog
x = SHBrowseForFolder(bInfo)

' Parse the result
path = Space$(512)
R = SHGetPathFromIDList(ByVal x, ByVal path)
If R Then
pos = InStr(path, Chr$(0))
GetDirectory = Left(path, pos - 1)
Else
GetDirectory = ""
End If
End Function

Function InStrLast(iStart As Integer, szSrchIn As String, _
szSrchFor As String, iCompare As Integer) As Integer
Dim iPrevFoundAt As Integer
Dim iFoundAt As Integer
On Error GoTo ErrExit_InStrLast
iPrevFoundAt = 0
iFoundAt = InStr(iStart, szSrchIn, szSrchFor, iCompare)
Do While iFoundAt > 0
iPrevFoundAt = iFoundAt
iFoundAt = InStr(iPrevFoundAt + 1, szSrchIn, szSrchFor, iCompare)
Loop
ErrExit_InStrLast:
If Err <> 0 Then MsgBox Error$, vbExclamation
InStrLast = iPrevFoundAt
Exit Function
End Function

The problem is that this code don't run in VB6 application. Is someone could tell me the modifications i have to done or where i can found somme vb6 code to solve this problem

What Is The Equivalent Function In WIN32 For The WIN16 Fn: GetModuleUsage%
What is the equivalent unction in WIN32 for the following WIN16 function:

Function GetModuleUsage% Lib "Kernel" (ByVal hModule%)

ExtractAssociatedIcon
I'm trying to set up a ListView to display a list of files, and I want the icon of each file to be displayed. I think I need to use the ExtractAssociatedIcon API, but I don't know how to get the extracted icon into the listview.

ExtractAssociatedIcon In An Image List
this is about API, but not just about the API. i wanna use AssociatedIcons for a program in using. It simply populates a folder of files. these files need to have the correctly associate icon displayed though. im using a listview control bound to an image list. what i need to information on howto go about using ExtractAssociatedIcon API to extract the icon, but rather than paint it to a hDC, add it to the imagelist. any ideas?

Cant Load This Icon! Why?
Hi!
I want to use this icon but VB wont let me, it tells me that it is an invalid format, dont know why... I can edit it with any icon editor, i save it again but still i cant use it... any idea???

Load Icon From An EXE Application
Hi all..

How to load icon from an application then saved in picturebox or imagebox?

I search arround the net but still cannot found the way.

Thank you so much.

ToolBar Btn Icon Load From DLL?
I am using VBA for Word 2003. Is there any way to load the icon picture for my toolbar buttons from a DLL or from the DOT file itself?

Thanks in advance.
--mam8526

Can Loadpicture Load An Icon?
can anyone give me a code fragment that will load an icon from C:TEMPMYICON.ICO into a picturebox?


i tried:

pb.Paintpicture LoadPicture("C: empmyicon.ico"), 0, 0, 32, 32


but nothing appears

Form Icon Does Not Load...
I have created a .ico file (from a .tif file) and tried to load as an icon in my form. But it gives an error message 'Invalid property value'. Could that be due to the different dimensions of the icon? or is there a different way to create/save .ico files? Please respond..

Load Icon At Runtime In StatusBar
Hi ,

Does anyone know how to load an icon into the StatusBar, at runtime ?

Element to be loaded: StatusBar1.Panels(0).Icon

What's the command to load the icon?

Thanks,
Joao.

Load Icon Directly Into Listview?
2 Questions:

First:
Is it possible to load an icon into a listview without first using an imagelist?

Second:
What is the most easy way to create something like a 'wizard'? Do I need a different form for each 'page' of a wizard of is there an easier way?

Thanx

Load Picture From Icon Library?
Is it possible to load a specified icon from an Icon Library (.icl) ? For instance:
Image1.Picture = LoadPicture("C:WindowsSystemshell32.dll,19")
doesn't work and returns a 'path not found' error. Is there a way to get the icon index number to load?

Getting Icon Property Causes Form Load
In my about box I want to display the same icon that is used for the main formwindow.
Thus, I coded

Sub Form_Load()
picIcon.Icon = frmmain.Icon
End Sub



in the frm module of my about box.

This works, of course, but it causes the main form to load again.
In fact, even printing "?frmmain.icon" in the immediate window causes the form window to be loaded again.

I use VB 6 and SP 2.

Yes, I could load the same Icon into the picture box of my about box, but that's not really what I want, because then I'd have to change the icon twice, whenever I decide to change it.

Any hints?

Load SMALL Icon Into Grid
I use a FlexGrid and want to put small (16x16) Icons in some of the cells.
When I use


set Grid.CellPicture = LoadPicture("C: empmyIcon.ico")




the large Icon is loaded (which, of course, doesn't fit in the cell).

How can I get the small icon ?


Thanks,


PUH

Load On Startup And Icon On System Tray
I want a program I made to be running in the background from startup (option set by user) and have an icon in the system tray.

Can anybody help me with those two things?

Thanks!

Load/Save From/to Txt?
I'm a beginner with visual basic. i guess we could start there..

Private Sub Save1_Click()
Open (App.Path & " emp.txt") For Output As #1
variabelone = Text1.Text
Print #1, variabelone
Close #1
End Sub

These rows will save whatever text there is in "text1" to a text document called temp. Some similar rows will load whatever temp.txt containes and output that in text2.

This far no problem. I wrote this to prepare myself for the saving part in a game im programming in visual basic. The problem with this system is that, to save a game in my game, you will need at least 300 of those txt:s. And that is not an option according to me.

I know it is possible in some very easy way, but i can't find anywhere telling my how to do it:

How can i save and load information to/from a specific Row in a text document? (so i can use ONE txt-file, containing 300 rows, instead of 300 files, containing one each...)

thanks //sam

Save/load
im srry if this was posted before but how do i save/load cause im makeing a game n i want a save/load in it but i dont know how.....help plz

LV1 Save / Load
How do I save the ListView1 data in a format so I can load all the data back into the columns? I don't know how to save it or load it back into the columns. Can someone show me an example or what I should look out for?

Thanks

Silver

Save/Load
I have a text editor, where, of course, I'll want to be able to Save/Load. I have 2 command buttons in a second form which I want to be able to click to open a Save Window. Now, I have managed to make a window open that lets me type in an address to save the file at, but I would like to be able to browse and save. The same thing goes with Load. Can anybody help?

Load/Save
Hi, can anybody help me? I'd like to know how I can save and load Caption(or another properties of Label) into/from a txt file?

Save/load
i just want a button to be save and one for load and when i click save it just saves a file with everything on the list and loads that again if i click on the load button

Save/load
does anyone know the code to save/load like a video game save/load. Ex Final Fantasy 7 u know how u can save then load when ever u want. ty if u can help and still waiting on help with other problem click here

Save/Load
Why wont this work?


VB Code:
Private Sub mnufileload_Click()    Dim TheSave As Integer    'load file    Dim MyFileName As String    CommonDialog1.DialogTitle = "Open File"    On Error GoTo No_Open    CommonDialog1.ShowOpen        Open CommonDialog1.FileName For Input As #1    TheSave = Input(1, I)    Close 1    lblcash.Caption = TheSave        Exit SubNo_Open:End Sub Private Sub mnufilesave_Click()    'save file    I = lblcash.Caption    CommonDialog1.DialogTitle = "Save File"    CommonDialog1.Flags = cdlOFNOverwritePrompt    On Error GoTo No_Save    CommonDialog1.ShowSave        Open CommonDialog1.FileName For Output As #1    Write #1, I    Close 1    No_Save:End Sub


thx in advance

Using VB To Load From And Save To A XML?
I have been searching for about 6 hours and have yet to find ANYTHING about saving to / loading from a XML in VB.

Any links/help would be appreciated

Thanks,
Replex


(The XML im trying to work with can be found here: http://www.angelfire.com/empire/httpgamesq/settings.xml copy + paste if it doesnt work)

Save/Load
What is incorrect in this code?
I am trying to save a string called save in savefile.txt.
Option Explicit

Dim listadd As String
Dim save As String
Dim x As Integer

Private Sub Command1_Click()

listadd = Text1.Text
save = listadd
List1.AddItem (listadd)

End Sub

Private Sub mLoad_Click()
Open App.Path & "savefile.txt" For Input As #1
Input #1, save
List1.AddItem (save)
Close
End Sub

Private Sub mSave_Click()
Open App.Path & "savefile.txt" For Output As #1
Write #1, List1.ItemData(x)
Close
End Sub

Save And Load
I have written this timesheet application, but I have run into a snag. When you first run it, it works great. I have it set up to put a msgbox up if there are not any times to calculate. Once you save it, then load it and run it, if there a no times to calculate it gives me a mismatch error. It seems to just skip the msgbox step and give me an error. Would anyone like to take a crack at this one. I am sure it is simple enough, I'm just not seeing it. I have attached the ZIP file for anyone interested. Perhaps someone can enlighten me on a better way to do it.

Thanks, Dave

Save And Load ???
hi i got this code from a firend,

Code:Private Sub ReadFromFile()
Dim LineOfText As String
Dim i As Integer

    Open Text2.Text For Input As #1
    On Error GoTo TooBig: 'set error handler
    Do Until EOF(1) 'then read lines from file
        Line Input #1, LineOfText
        Text1(i).Text = LineOfText
        i = i + 1
    Loop

CleanUp:
    Close #1 'close file
    Exit Sub
TooBig: 'error handler displays message
    MsgBox ("The specified file is too large.")
    Resume CleanUp: 'then jumps to CleanUp routine
End Sub

Public Sub WriteToFile()
Dim i As Integer
Dim ctrl As TextBox
     
    Open Text2.Text For Output As #1
     
    For Each ctrl In form19.Text1
        Print #1, Text1(i).Text
        i = i + 1
    Next

    Close #1 'close file
End Sub

and i got no idea where it saves or loads to, the file name

can you guys help


 

Save/load
Hi all!
I wrote a piece of software and I need to insert a couple buttons that would save and load the settings. I already export all the settings to some .txt files. But what if I want to import them back and make all the checkboxes and buttons corespond to the saved settings. I have no idea on how to start on even creating the menus to save to a file and load from a file (you know, like a save and an open button in word for example). Please send me any pointers or maybe websites that have articles about this problem.
Thanks.

Load Icon From Resource File Into Picture/Image Box?
Is this possible? Can't figure it out, just keep getting errors. I have a resource in my project containing an icon indexed as AAA...

Save The Icon
Hello all..
How to get the icon that is associate with the file?

I have email item... which contain file attachments..
So first get the file attachment using mail.Attachments and mail.Attachment. Up to here no problem..

here the code to get the icon and saving it in C:PCKM so I can call the image file from HTML code



Code:

Function GetIconLocation(ByVal filename As String) As String
Dim loc As String
'Use this to get the small icon.
Dim fName As String 'The file name to get the icon from.
Dim shinfo As SHFILEINFO
shinfo = New SHFILEINFO
Dim openFileDialog1 As OpenFileDialog
openFileDialog1 = New OpenFileDialog
Dim hImgSmall As IntPtr 'The handle to the system image list.

hImgSmall = SHGetFileInfo(filename, 0, shinfo, Marshal.SizeOf(shinfo), SHGFI_ICON Or SHGFI_SMALLICON)
Dim hIcon As Icon
hIcon = Icon.FromHandle(shinfo.hIcon)

Dim bip As System.Drawing.Bitmap
bip = hIcon.ToBitmap()
bip.Save("c:pckmicon.bmp")
loc = "<img src=""c:pckmicon.bmp""><br>" & filename

GetIconLocation = loc
End Function


After I saved the icon.bmp I try to open it by double clicking the file or using open with to oen the file but can't open with any other programs

How to save the icon to the hard drive???

Thank you

Is There A Set Load And Save Window?
Hi guys, Ive made a Load window, in which you can choose ur drive and directory, and select a file but its abit ropey. so is there any set examples out there?

Cheers

How To Save/load A Game
Hiya,

I did a search of the forums, but I did not find any clear information on how to write the code for saving and/or loading a game.

Basically, I'm working on a kingdom simulator that is full of different variables, such as Treasury amount, population size, taxation level, industrial population size, etc.

I'm looking for a code that would let me save the game and also let me load it from a while later on so I can continue playing from where I left off.

Any suggestions?

Thanks in advance

Save / Load Map In DirectX 7.0
I would like to have feature that let users to type in the filename they want to save , and also to load their desired file with filename shown in a custom designed box .

So far i have thought of some ideas on how to do the saving part ,
that is to use Directinput , drawtext for typing the text ( filename) , and then save it using I/O function ( not entirely sure this is the right way). but i 'mhaving difficult on figuring out a way to do the file loading part during in game process.

ANy help would be greatly appreaciated

Save/Load Listbox
I have the following code in a modual and it works fine when called form one. I close form one and open form two and when called it says the file dosen't
exist. I've even tryed hard coding the full path in form two and get the same result.

Public Sub LoadList(Dir As String, SpellingList As ListBox)

Dim I As Integer

Dim Word As String

On Error GoTo ERR:

I = FreeFile
Open Dir For Input As #I
Do While Not EOF(I)
Input #I, Word
SpellingList.AddItem Word
Loop
Close #I
Exit Sub

ERR:
MsgBox "File dosen't Exist"

End Sub

Load And Save Programs
i am working on a text editer and i wondering how to save and load my programs

i am also trying to figure out how to display the line and charecter number on a status bar!

Any Ideas?

Save/Load Picture On DB
Hello, Iss there any body who know coding for Save and Load Picture on Database (SQL 2000)

thnx

Yasir

Save &amp; Load A File
iv got 3 text box's, studentID, firstname, and last name. and two command buttons, write and read.

this is the code iv used to write it:

recordlength = Len(student)
filenumber = FreeFile

Open "c: est.fil" For Random As filenumber Len = recordlength
Put #filenumber, 1, student
Close #filenumber

Text1.Text = studentid
Text2.Text = student.FirstName
Text3.Text = student.LastName

wen i look at the file though, the data hasnt wrote to it but it has spaces wer the data should be, so it has done something.

can any1 help me get it to write properly please so that when i open the file it contains the text that i have inputted?

Save/Load Dialog
Hello Everybody,

I've searched through the forum, but I can't find it anywhere, how can I get my program to show the save thing, which is also shown when you save wordt or so, and how does it work, can I add makss and stuff like...any tutorial or comment on this would be great

Create Save And Load
Is there a way I can create a secure file (In a direcotry chosen by the user) that can only be read be VB and it must be able to save a look up information inputted by the user. I.E. names

File Load And Save?
What the heck am i doing wrong? I have a textbox that i am entering notes into. The form wont get closed much but when it does i need it to the save notes in a text file. Here's code im using:

Dim notesave as string
open "c:documents and settingsowner
otes.txt)" for output as #1
notesave = text1.text
print #1, notesave
close #1

AND

Dim noteload as string
open "c:documents and settingsowner
otes.txt)" for input as #1
input #1, noteload
text1.text= noteload
close #1

I dont have any save or load buttons, i want the notes to be written to the file and saved when the form is exited. Now when i load program back up i want to open file and add my saved notes into the text1.text again. Basically just want my info loaded and saved everytime i load and exit. Thanks for any help, has me stumped.

Auto Save Load Again
I've already asked this question once but i didnt understand any of the replies:
I want to open my program, and when i close it i want the items in list1 to save to a textfile in the same folder as the program.
and when i open my program i want the text from a textfile in the same folder to load into list1
Whats the code?

Copyright © 2005-08 www.BigResource.com, All rights reserved