Solved

Help needed asap.

Posted on 1998-07-23
12
159 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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
 

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month7 days, left to enroll

622 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