Solved

Help needed asap.

Posted on 1998-07-23
12
152 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Use Multiple Forms 4 48
VBA Word macro - how to get characters after the searched for string 5 66
Spell Check in VB6 13 95
how to know if my Checkbox is True in VB6.0? 9 36
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

943 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

6 Experts available now in Live!

Get 1:1 Help Now