Solved

Help needed asap.

Posted on 1998-07-23
12
150 Views
Last Modified: 2010-05-03
REPLIES ARE NEEDED URGENTLY TO THIS QUESTION.

Hi all,
  need to know how to do the following:

  Make and delete directories
  Make and delete files
  Make, Edit, and Remove Registry Keys.

Kind Regards,
Rob Green.
0
Comment
Question by:robjgreen
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 9

Expert Comment

by:Dalin
ID: 1466520
Rob,
Create file: Open filename for Output/append
Delete file: Kill filename
Create dir:  MKDir dirPathName
Delete Dir:  RMDir DirPathName
Create Regi: RegCreateKey API
Delete Reg:  RegDeleteKey API

Let me know if I can help further
Regards
Dalin
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1466521
BTW, I send you some questions regarding your code. Have you got it? I guess you are about 5 hours ahead of me (I am in US, Eastern time zone).
0
 

Expert Comment

by:joe_s
ID: 1466522
Rob,

To save/create a registry settings:
SaveSetting("appname_here", "App section here", "LastNoConnect", sLastConnectTime)

To read a registry setting:
sLastConnectTime = GetSetting("appname_here", "App section here", "LastNoConnect", "")

Joe
0
 

Author Comment

by:robjgreen
ID: 1466523
Dalin, can you give examples? I am useless with api.
0
 

Accepted Solution

by:
usermiles earned 100 total points
ID: 1466524
Below are the API functions to create, Delete, and Edit

'hkey=The root key under which is used to creat the new key
'lpSubKey=The name of the new SubKey to create
'phkResult=If the function works this result will contain the handle to the new key, and this API will return a long value of 0 if the function was successful, any other values are considered errors..

Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long

Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long

Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long


All API calls should be declared Private, after the Option Explict command.


Kill "Filename"      ' Delete file.
Open "TEST" & MyIndex For Output As #FileNumber      ' Create filename.
      

RmDir "DirectoryName"      ' Removes DirectoryName.
MkDir "MYDIR"      ' Make new directory or folder.

0
 
LVL 6

Expert Comment

by:alamo
ID: 1466525
Beware, you usually want to use the Ex versions of the registry functions (e.g. RegSetValueEx). The older functions can only set REG_SZ type keys and can't deal with the multiple named values under a single key that is how much of the 9x/NT registry is set up.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:robjgreen
ID: 1466526
Thanks guys, pity I cant split the points between you though. If anyone can recommend a book on API I would be very grateful because the microsoft books "Step by Step" and "Programmers Guide" dont really contain much advanced info.

Kind Regs,
Rob Green.
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1466527
Rob,
Sorry I was unable to follow up. I had to go to a "Radiation Safty training" offsite all afternoon.  I am glad usermiles was able to give you examples.

Just a comments on APIs, You can have the API viewer (comes with VB) and load the WIN32API.txt file, and look for the API you need, it will give you the proper declaration. you can copy it to your VB code.

You can also find all the explaination of the API's in microsoft's MSDN online library.
Regards
Dalin
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1466528
Regarding to book, Dan Appleman's book is a good one:
VB5 Programmer's Guide to the Win32 API.
0
 

Author Comment

by:robjgreen
ID: 1466529
Thanks again all....

Anybody know why it puts the directory under VB and VBA though rather than its own key?

Also, if anybody has any ideas on a twenty day trial system then I would be mucho glad. No need for password protection etc, already done that part of it.

Kind Regs,
Rob Green.
0
 

Expert Comment

by:usermiles
ID: 1466530
I would recommend the Dan Appleman's book for VB4.0 it actually gives better examples for the API functions, it is the same as VB5 but with a little better detail...

Miles
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1466531
Rob,
I had trouble to logon myemail.
Here is what you do for add to the start menu:

'Declare:
Private Declare Function fCreateShellLink Lib "vb5stkit.dll" _
    (ByVal Forder As String, ByVal ShortCutName As String, _
     ByVal ExePath As String, ByVal Params As String) As Long


'Code
 Dim ret As Long
' add shortcut to DeskTop
' ret = fCreateShellLink("..\..\Desktop", "TheNameAppear", "YourAppwithPath.exe", "")

 'To the system Start Menu
 ret = fCreateShellLink("..", "CodeBank", "c:\Dalin\VBUtil\CodeBAnk\CodeBank.exe", "")

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now