Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help needed asap.

Posted on 1998-07-23
12
Medium Priority
?
163 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

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

Accepted Solution

by:
usermiles earned 300 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

916 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